i have a VideoView that i know how to center it on the screen, but now i need to specify dinamically (java code, not xml code) the position on the screen.
This is my actual code:
VideoView vv = new VideoView(this);
this.setContentView(vv);
android.widget.FrameLayout.LayoutParams vvParams = (android.widget.FrameLayout.LayoutParams) vv.getLayoutParams();
vvParams.gravity=17; //gravity 17 = center horizontal & vertical
vvParams.width=150;
vv.setLayoutParams(vvParams);
String fileName = "android.resource://" + getPackageName() + "/" + R.raw.v;
vv.setVideoURI(Uri.parse(fileName));
vv.start();
These are the possible positions i want to specify:
(vertical/horizontal)
- top left, top center, top right
- center left, center center, center right
- bottom left, bottom center, bottom right
How to specify these possitions with java code dinamically?
Make your VideoView the child of a
RelativeLayout, and then update the LayoutParams like this: