Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
747 views
in Technique[技术] by (71.8m points)

android - Center VideoView in landscape mode

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. :)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can put it in a LinearLayout instead and set it's gravity to CENTER, or just put CENTER_IN_PARRENT in your addRule() method of RelativeLayout :)

Good luck!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...