i need to create a video view which should lie just beneath the one with id "video1" at run time. The code works fine for creating the view, but I am not able to place it below the videoView with id "video1". Here is the code:
RelativeLayout layout = findViewById(R.id.layout);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)
layout.getLayoutParams();
params.addRule(RelativeLayout.BELOW, R.id.video1);
videoView2 = new VideoView(jazz.this);
videoView2.setLayoutParams(params);
videoView2.setLayoutParams(new
FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, 200));
layout.addView(videoView2);
This is your code:
videoView2.setLayoutParams(params);
videoView2.setLayoutParams(new
FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, 200))
You set the LayoutParams twice...
Use this:
VideoView v = new VideoView(context);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, 200);
layoutParams.addRule(RelativeLayout.BELOW, R.id.video1);
v.setLayoutParams(layoutParams);
container.addView(v);
It will be work. hople to help you