2017-03-15 27 views
-3

コード私はビデオビューを全画面にして上に閉じる画像ビューを配置する方法は?ここ

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/activity_video_player" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 
<VideoView 
    android:id="@+id/videoView" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    /> 
<ImageView 
    android:layout_gravity="top|right" 
    android:src="@android:drawable/ic_menu_close_clear_cancel" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" /> 

</FrameLayout> 

を試してみましたされたが、結果のレイアウトは、次のようになり、この videoview

フルスクリーンを占有するビデオを作成すると終了ImageViewの右上の位置にビデオの上に表示されるはずですか?

+0

。相対レイアウトとフレームレイアウトを使用すると、close_imageビューのlayout_gravity = "top | right"と同じ結果を得ることができます。 – Geek

+0

@ tahsinRupam私はあなたのコードを試しましたが、それは動作していませんでした。 –

答えて

2

トリックで、これを試してみてください。あなたは大丈夫です使用何

<RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

    <VideoView 
     android:id="@+id/videoView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentTop="true" 
     android:fitsSystemWindows="true" 
     /> 
    <ImageView 
     android:layout_gravity="top|right" 
     android:src="@android:drawable/ic_menu_close_clear_cancel" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentRight="true" /> 
    </RelativeLayout> 
+0

ありがとうございます。あなたの提案は完全に機能します。 –

0

はここ

<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <RelativeLayout 
      android:id="@+id/relativeLayout" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_margin="20dp"> 

      <VideoView 
       android:id="@+id/videoView" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:fitsSystemWindows="true" /> 
     </RelativeLayout> 

     <ImageView 
      android:layout_width="30dp" 
      android:layout_height="30dp" 
      android:layout_alignParentEnd="true" 
      android:layout_alignParentTop="true" 
      android:layout_margin="10dp" 
      android:src="@drawable/placeholder" /> 

    </RelativeLayout> 
1
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    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_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" /> 

    <ImageView 
     android:id="@+id/close_logo" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" 
     android:scaleType="centerCrop" 
     android:src="@drawable/button_close" /> 
</RelativeLayout> 
関連する問題