2016-04-27 7 views
-1

Videoview Androidのは、これが彼のXMLセンタービデオ - 特定のビデオを果たしている私は、ビデオのビューを持っている

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="horizontal" android:layout_width="match_parent" 
    android:layout_height="match_parent"> 



Some other views 


    <VideoView 
     android:id = "@+id/video" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_gravity="center" 
     android:layout_alignParentStart="true" 
     /> 



</RelativeLayout> 

私がプレー今までとき、私はまだ、それにビデオを中央にしようとしていますですビデオ、 これは中心には表示されず、場所の変更はビデオに依存しますが、どのように中心化しますか?

+0

の試みで示します'Video View'で' android:layout_centerInParent = "true"。 –

+0

は役に立たなかった – 2D3D

+0

http://stackoverflow.com/questions/10518283/fullscreen-videoview-isnt-centeredの可能な複製 –

答えて

4

@jaydroiderは、あなたがこの例では=真

layout_centerInParentを使用することができ、言われたように、私は、幅と高さを変更し、メインレイアウトの背景色を変更しました。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" 
    android:background="@android:color/white"> 

    <VideoView 
     android:id="@+id/video" 
     android:layout_width="200dp" 
     android:layout_height="200dp" 
     android:layout_centerInParent="true" 
     android:layout_gravity="center" /> 

</RelativeLayout> 

アンドロイドを使用しないでください:layout_alignParentTop = "true" をアンドロイドは:layout_alignParentStart = "true" をは、あなたがそれを使用している場合ので、レイアウトは常にTOP/LEFT位置

関連する問題