こんにちは、向きの変更を再生する際にこの問題があります。縦向きでは、レイアウト ディレクトリに次の XML があります。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<!-- Player Header -->
<LinearLayout
android:id="@+id/player_header_bg"
android:layout_width="fill_parent"
android:layout_height="60dip"
android:background="@layout/bg_player_header"
android:layout_alignParentTop="true"
android:paddingLeft="5dp"
android:paddingRight="5dp">
<!-- Song Title -->
<TextView
android:id="@+id/videoTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#04b3d2"
android:textSize="16sp"
android:paddingLeft="10dp"
android:textStyle="bold"
android:text="@string/song_def_title"
android:layout_marginTop="10dp"/>
<!-- Full Screen button -->
<ImageButton
android:id="@+id/btnFullScreen"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/ic_action_refresh"
android:background="@null" />
<!-- Playlist button -->
<ImageButton
android:id="@+id/btnPlaylist"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/btn_playlist"
android:background="@null"/>
</LinearLayout>
<VideoView
android:id="@+id/surface_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/player_header_bg" >
</VideoView>
</RelativeLayout>
向きが横向きに変わると、レイアウトランドフォルダーにこのXMLがあり、同じXMLファイル名ですが、次のXMLがあります
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<VideoView
android:id="@+id/surface_view"
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" >
</VideoView>
</RelativeLayout>
向きは問題なく変わりますが、横向きモードでアクションバーと通知バーに乗りたいと思いました。ポートレートモードで出てきます。
onConfigurationChanged メソッドを手動でオーバーライドしようとしましたが、うまくいきません。
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
ActionBar actionBar = getActionBar();
actionBar.hide();
WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
getWindow().setAttributes(attrs);
// setContentView(R.layout.player_video_fs);
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
ActionBar actionBar = getActionBar();
actionBar.show();
WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.flags |= WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN;
getWindow().setAttributes(attrs);
// setContentView(R.layout.player_video);
}
}
上記を実行すると、横向きに変更するとアクションバーと通知バーが削除されますが、縦向きに戻すとアクションバーが少し奇妙になります。それがどのように切断されるかを参照してください。アクションバー
ランドスケープに変更すると、ビデオの再生を続行する代わりに、ブラックスクリーンになるようです。
他の方法をいくつか試しましたが、まだ解決できません。何か案が?