Fullscreen VideoView isn't Centered

前端 未结 5 1549
遥遥无期
遥遥无期 2021-01-19 10:36

I use this XML layout to show a fullscreen VideoView on my activity. The Video is fullscreen but it isn\'t centered. In landscape mode, it stays on the left side of the scre

相关标签:
5条回答
  • 2021-01-19 10:37

    You need to have two different layouts. One for the portrait and the one for the landscape. Create two xml files with the same name and put them into folders "layout-land" for landscape and "layout-port" for portrait.

    And Here you can take a look how to handle orientation changes.

    This can be the layout to make video view full screen.

    0 讨论(0)
  • 2021-01-19 10:38

    3 down vote accepted

    You need to have two different layouts. One for the portrait and the one for the landscape. Create two xml files with the same name and put them into folders "layout-land" for landscape and "layout-port" for portrait.

    And Here you can take a look how to handle orientation changes.

    This can be the layout to make video view full screen.

    0 讨论(0)
  • 2021-01-19 10:44

    Try this:

    <?xml version="1.0" encoding="utf-8"?>
     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
               android:layout_width="fill_parent"
               android:layout_height="fill_parent" >
       <VideoView android:id="@+id/myvideoview"
                 android:layout_width="fill_parent"
                 android:layout_height="fill_parent"
                 android:layout_centerInParent="true">
        </VideoView>
     </RelativeLayout>
    

    Hope this helps.

    0 讨论(0)
  • 2021-01-19 10:56

    Try this layout,

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
      xmlns:android="http://schemas.android.com/apk/res/android"              
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="center"
      android:gravity="center">
    
    
    
             <VideoView android:id="@+id/videoview"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_centerInParent="true"/>
    
    </RelativeLayout>
    
    0 讨论(0)
  • 2021-01-19 10:59

    If your VideoView cannot center in RelativeLayout you can try to put it into a FrameLayout like this:

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <VideoView
            android:id="@+id/video_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center">
        </VideoView>
    
    </FrameLayout>
    

    And then put this into RelativeLayout.

    0 讨论(0)
提交回复
热议问题