簡體   English   中英

視頻視圖中的Android全寬

[英]Android Full Width in Video View

我試圖將線性布局或相對布局內的視頻視圖拉伸到全屏,但是應用程序沒有將視頻視圖的寬度拉伸到android屏幕。 左右兩側始終有10到15 dp空間。 線性布局以及相對布局也不會延伸到全屏。 我希望它以width填充屏幕。我也嘗試過使用“ match_parent”代替“ fill_parent”,但結果是相同的。 這是我的代碼

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res    /android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bgsong"
android:orientation="vertical"
 >

<VideoView
    android:id="@+id/video_view"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true" />

video_player_view = (VideoView) findViewById(R.id.video_view);
    dm = new DisplayMetrics();
    this.getWindowManager().getDefaultDisplay().getMetrics(dm);
    int height = dm.heightPixels;
    int width = dm.widthPixels;
    video_player_view.setMinimumWidth(width);
    video_player_view.setMinimumHeight(height);
    Uri uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.video);
    video_player_view.setVideoURI(uri); 
    video_player_view.start();
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent" >

<VideoView
    android:id="@+id/videoView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_centerInParent="true"
    android:layout_centerVertical="true" />

</RelativeLayout>

實際上,視頻的長寬比與屏幕的長寬比不匹配,這就是您遇到此類問題的原因,如果要繼續進行此操作,並且UI看起來已經很漂亮,只需將背景色設置為LinearLayout android:background="#000000"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM