1

Activity unterstützt Landscape ModusonBackPressed() Ausrichtung Ausgabe

<activity 
     android:name=".MainActivity" 
     android:configChanges="orientation|screenSize|keyboardHidden" 
     android:screenOrientation="landscape" 
     android:label="@string/app_name" > 

, wo ich 50% Platz auf Video Player zugeordnet haben (unter Verwendung von FrameLayout) und 50% auf ListView ruhen.

<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> 

Nun habe ich begonnen Video spielen>auf Vollbild Modus bewegt>zurückgedrückt Vollbild Modus >bekommen Aktivität in Portrait-Modus zu verlassen (während Ich war erwartet, es in Landschaft Modus zu erhalten)

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

http://stackoverflow.com/a/11310902/3790150 – saeed

Antwort

1

/* Ich bin mir nicht sicher, können Sie diese Codezeile in die Rückdruckmethode einfügen? */

Log.d("boolean:-", Boolean.toString(isFullScreen)); 
    if(isFullScreen) { 
     imaPlayer.getContentPlayer().setFullscreen(false); 
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); 
    } 
    else { 
     super.onBackPressed(); 
    } 
+0

Nun, wenn ich mich auf Rückansicht im Querformat-Modus bin immer, aber immer noch, wenn ich auf der Schaltfläche tippen tun, die in Video-Player kommen Beenden Sie den Vollmodus immer noch im Portrait-Modus Warum? – Sophie

+0

in onResume() -Methode setzen Sie diese Codezeile und überprüfen Sie setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); –

Verwandte Themen