2017-04-20 6 views
0

Bei Verwendung immersive mode mit viewPager Ansicht ->fullscreen_content ist nicht auf Fullscreen-Größe.Immersive-Modus mit ViewPager

Aber mit dem gleichen Code in der Vorlage von Android-Studio zur Verfügung stellen funktioniert es gut.

Meine beste Schätzung ist, dass es etwas mit android:fitsSystemWindows="true" zu tun hat.

Wenn Sie den Screenshot unter Ihnen sehen, ist die grüne Farbe der Hintergrund der Ansicht, die android:fitsSystemWindows="true" verwendet und eine helle Farbe wird als Hintergrund der gesamten Aktivität für das Debuggen verwendet.

Was ist die Lösung & gibt es anders herum?

XML Aktivität immersiver

<FrameLayout 
    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" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    tools:context=".Camera.CameraActivity"> 

    <FrameLayout 
     android:fitsSystemWindows="true" 
     android:background="@color/colorAccent" 
     android:id="@+id/fullscreen_content" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"/> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     tools:context=".Camera.CameraActivity"> 

     <com.brotherpowers.audiojournal.View.AJViewPager 
      android:id="@+id/container" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"/> 

     <com.viewpagerindicator.CirclePageIndicator 
      android:id="@+id/viewpager_indicator" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_centerHorizontal="true" 
      android:padding="@dimen/spacing.8" 
      app:fillColor="@color/viewpager_active" 
      app:pageColor="@color/viewpager_inactive" 
      app:strokeColor="@android:color/transparent"/> 

    </RelativeLayout> 

</FrameLayout> 

JAVA Aktivität zeigen Umsetzung/Vollbild

private final Handler uiHandler = new Handler(); 
    private boolean fullScreen; 

    private void hide() { 
     // Hide UI first 
     ActionBar actionBar = getSupportActionBar(); 
     if (actionBar != null) { 
      actionBar.hide(); 
     } 
     fullScreen = true; 

     // Schedule a runnable to remove the status and navigation bar after a delay 
     uiHandler.removeCallbacks(showRunnable); 
     uiHandler.postDelayed(hideRunnable, 100); 
    } 


    private void show() { 
     // Show the system bar 
     _contentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 
       | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); 
     fullScreen = false; 

     // Schedule a runnable to display UI elements after a delay 
     uiHandler.removeCallbacks(hideRunnable); 
     uiHandler.postDelayed(showRunnable, 100); 
    } 

    private final Runnable showRunnable =() -> { 
     // Delayed display of UI elements 
     ActionBar actionBar = getSupportActionBar(); 
     if (actionBar != null) { 
      actionBar.show(); 
     } 
     _contentView.requestLayout(); 
    }; 

    private final Runnable hideRunnable =() -> { 
     // removal of status and navigation bar 
     _contentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE 
       | View.SYSTEM_UI_FLAG_FULLSCREEN 
       | View.SYSTEM_UI_FLAG_LAYOUT_STABLE 
       | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY 
       | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION 
       | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); 

     _contentView.requestLayout(); 
    }; 

screencast

Antwort

-1
verstecken
@Override 
public void onWindowFocusChanged(boolean hasFocus) { 
    super.onWindowFocusChanged(hasFocus); 

     final int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE 
       | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION 
       | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 
       | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION 
       | View.SYSTEM_UI_FLAG_FULLSCREEN 
       | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; 

     SystemUiHelper uiHelper = new SystemUiHelper(this, SystemUiHelper.LEVEL_IMMERSIVE ,flags); 
     uiHelper.hide(); 



} 
+1

keine Kommentare, keine Erklärung. Code nur Antwort = schlechte Antwort. – WarrenFaith