3
我正在開發Android應用程序。我需要在橫向模式下播放視頻,而視頻視圖應該位於屏幕的中央,但它正在播放屏幕左上角的視頻。這是我的代碼,Android風景視頻中心
<VideoView
android:id="@+id/videoView1"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" >
請幫助我。提前致謝。如果你想這樣做在Java代碼
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
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"/>
<!-- Put Your Admob Layout here and it will work as you want. -->
</RelativeLayout>
更新
的參考這個:
- 謝謝你這麼多,它的做工精細:)我需要AdMob廣告是在videoview的頂部顯示。它不適用於此。你能幫我註冊嗎? – Naveen
查看更新後的佈局,並在其中放置您的admob佈局。它會幫助你。並接受答案,如果你的問題解決它所以它可以幫助別人。 –
該解決方案非常適合將視頻集中到VideoView中! – Gibberish