1

Video View を使用して Android でビデオを再生しようとしていますが、ビデオが画面に合わせて完全に伸びているわけではなく、代わりにビデオ ビューが伸びており、画面の両側に黒い空の画面が表示されています。

縦横比を考慮せずに動画をストレッチしたい。

これに関するヘルプ

ありがとう&ナゲンドラ

XML:

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

    <VideoView android:id="@+id/myvideoview"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" />

</RelativeLayout>

コード:

setContentView(R.layout.main);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
videoPlayer = (VideoView) findViewById(R.id.myvideoview);
String uri = "android.resource://" + getPackageName() + "/" + R.raw.video;

videoPlayer.setVideoURI(Uri.parse(uri)); 
videoPlayer.setMediaController(new MediaController(this));
videoPlayer.requestFocus();
videoPlayer.setVisibility(0);
videoPlayer.start();

これは私がビデオを再生するために使用しているコードです

お返事をありがとうございます

4

2 に答える 2

2

あなたができるトリックは、VideoViewa の中に入れRelativeLayoutてパラメータを追加することです:

android:layout_alignParentRight="true" android:layout_alignParentLeft="true" 
android:layout_alignParentTop="true" android:layout_alignParentBottom="true"

これにより、ビデオがフルスクリーンに「引き伸ばされ」ます。ビデオAspectRatioが十分に良ければ、非常に良い結果が得られます

于 2013-11-02T18:24:32.157 に答える
0

VideoView の xml で、layout_width と layout_height に fill_parent を使用します。

<VideoView android:layout_height="fill_parent"
android:layout_width="fill_parent" android:id="@+id/VideoView"></VideoView>
于 2011-06-23T06:10:53.060 に答える