PLATFORM縦向きにプレイしていない:AndroidのSDKを使用してEclipseで開発 を16アンドロイドVideoViewは
問題: 私は480X800で画面全体を埋めることになっているVideoView要素(PORTRAITを持っていますオリエンテーション)、それは上手く再生されますが、肖像画に向きません。それはランドスケープモードに固執し、アスペクト比はそのようにゆがめられます。
- をアンドロイド使用:screenOrientationは= "ポートレート" をマニフェスト
- にアンドロイド使用:setRequestedOrientationを用いて容器の配向= "垂直" 及びVideoView自体
- を私が試みているもの
(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);私は、ディスプレイ
を回転させる480PXのx 800dpにVideoView幅と高さを設定しようとする代わりに、fill_parent - オートスイッチをオフfill_parent
- の代わりに480dpx800dpするために、レイアウトの幅と高さを設定しようとしてsetContentView
- を呼び出す直前
XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="480dp"
android:layout_height="800dp"
android:background="#000000"
android:orientation="vertical" >
<VideoView
android:id="@+id/opening_video"
android:layout_width="480dp"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_height="800dp"
android:orientation="vertical" />
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/transparent_button"
android:contentDescription="@string/back_button_desc"
android:background="@android:color/transparent" />
</RelativeLayout>
CODE:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setContentView(R.layout.activity_start_screen);
VideoView videoView = (VideoView) findViewById(R.id.opening_video);
Uri pathToVideo = Uri.parse("android.resource://com.example.consumerengage/" + R.raw.opening_tablet);
videoView.setVideoURI(pathToVideo);
videoView.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.setLooping(true);
}
});
videoView.requestFocus();
videoView.start();
// boolean isPlaying = videoView.isPlaying() ;
// videoView.stopPlayback();
// videoView.clearFocus();
addListenerOnButton();
}
質問:私が試みた 何も成功しませんでした。 480x800のビデオを縦向きで再生するにはどうすればよいですか?
XMLを上記の設定に変更すると、ビデオは水平方向に再生され、垂直方向には再生されません。 –
@RickSあなたがしている間違いは、あなたのレイアウトとビデオビューに固定された高さと幅を定義することです。デフォルトのマッチ・ペアレントを使用し、マニフェスト・ファイルのアクティビティでandroid:screenOrientation = "portrait"と書いてください。 –
android:screenOrientationをmanifeastファイル – AMD