2016-09-30 52 views
0

我在視頻視圖中有一段視頻,播放和循環作爲我的登錄/註冊活動的背景。視頻播放和循環很好,但它不覆蓋整個屏幕。該活動被鎖定在肖像模式下,但視頻僅顯示在屏幕的下半部分(就像在橫向模式中一樣)。 videoview本身覆蓋了整個屏幕。這是我現在的代碼。以縱向模式在videoview全屏中製作視頻

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_launcher); 

    VideoView videoView = (VideoView) findViewById(R.id.launcherVideo); 
    Uri src = Uri.parse("android.resource://com.package/raw/video"); 
    videoView.setVideoURI(src); 

    videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { 

     @Override 
     public void onPrepared(MediaPlayer mp) { 

      mp.setVolume(0, 0); 
      mp.setLooping(true); 
     } 
    }); 

    //videoView.setMediaController(new MediaController(this)); 

    videoView.start(); 
} 

這是我的XML

<VideoView 
    android:id="@+id/launcherVideo" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_above="@+id/linearLayout" /> 

如何使視頻全屏任何規模大小的設備上?

回答

0

你可以嘗試使用TextureView代替VideoView,因爲這answer描述

1

沒有見過的整個佈局的xml,我想this可能會有幫助。

嘗試用RelativeLayout的包裹你的VideoView並使其與父:

<VideoView 
    android:id="@+id/launcherVideo" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentRight="true"> 
+0

謝謝你的男人,其工作對我來說 –

相關問題