onBackPressed() 方向问题
onBackPressed() Orientation Issue
Activity
支持Landscape
模式
<activity
android:name=".MainActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="landscape"
android:label="@string/app_name" >
我已将 50% space 分配给 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>
现在,我已经开始播放视频 > 切换到全屏模式> 按回退出全屏模式> 获得Activity纵向 模式(而我 期望在横向 模式下获得它)
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();
}
}
/* 我不确定,你能把这行代码放在 back pressed 方法中吗? */
Log.d("boolean:-", Boolean.toString(isFullScreen));
if(isFullScreen) {
imaPlayer.getContentPlayer().setFullscreen(false);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
else {
super.onBackPressed();
}
Activity
支持Landscape
模式
<activity
android:name=".MainActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="landscape"
android:label="@string/app_name" >
我已将 50% space 分配给 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>
现在,我已经开始播放视频 > 切换到全屏模式> 按回退出全屏模式> 获得Activity纵向 模式(而我 期望在横向 模式下获得它)
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();
}
}
/* 我不确定,你能把这行代码放在 back pressed 方法中吗? */
Log.d("boolean:-", Boolean.toString(isFullScreen));
if(isFullScreen) {
imaPlayer.getContentPlayer().setFullscreen(false);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
else {
super.onBackPressed();
}