How can I center a VideoView
in landscape mode? I tried this: on Manifest file I have :
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
and on my Activity I have this code:
RelativeLayout.LayoutParams lv= new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
lv.addRule(RelativeLayout.CENTER_HORIZONTAL);
myVideoView = new VideoView(this);
myVideoView.setLayoutParams(lv);
myVideoView.setVideoPath(Environment
.getExternalStorageDirectory()
+ "/BouyguesImages"
+ "37" + "/" + "89Video");
myVideoView.requestFocus();
and this VideoView I add it as a View to a RelativeLayout :
rr = new RelativeLayout(this);
rr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
rr.setBackgroundColor(Color.WHITE);
The result of my code is that my video is playing only in the top part of the screen and at the bottom the screen is white (relativelayout's color). I want to fit the VideoView on screen, so to have a small part white on the bottom of the screen, and on top of the screen to. How to do this?
Thanks in advance. :)
You can put it in a
LinearLayout
instead and set it's gravity toCENTER
, or just putCENTER_IN_PARRENT
in youraddRule()
method ofRelativeLayout
:)Good luck!