Activity
支持Landscape
模式
<activity
android:name=".MainActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="landscape"
android:label="@string/app_name" >
我已将50%的空间分配给Video Player
(使用FrameLayout),并将50%的空间分配给ListView
。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/video_frame"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<ListView
android:id="@+id/video_list_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
现在,我已开始播放视频 &gt; 已移至全屏模式&gt; 按下以退出全屏模式&gt; 以纵向模式获取活动(而我希望以横向模式获取它)
boolean isFullScreen = false;
@Override
public void onGoToFullscreen() {
isFullScreen = true;
videoListView.setVisibility(View.INVISIBLE);
}
@Override
public void onReturnFromFullscreen() {
videoListView.setVisibility(View.VISIBLE);
}
@Override
public void onBackPressed() {
Log.d("boolean:-", Boolean.toString(isFullScreen));
if(isFullScreen) {
imaPlayer.getContentPlayer().setFullscreen(false);
}
else {
super.onBackPressed();
}
}
答案 0 :(得分:2)
/ *我不确定,你能把这行代码放在按下的方法上吗? * /
Log.d("boolean:-", Boolean.toString(isFullScreen));
if(isFullScreen) {
imaPlayer.getContentPlayer().setFullscreen(false);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
else {
super.onBackPressed();
}