2016-04-28 3 views
0

Ich habe so eine Oberflächenansicht erstellt.FullScreen für SurfaceView funktioniert nicht in Lollipop oder höher

content_main.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="0dp" 
    android:paddingLeft="0dp" 
    android:paddingRight="0dp" 
    android:paddingTop="0dp" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="com.networks.streaming.surfaceviewfullscreentest.MainActivity" 
    tools:showIn="@layout/activity_main"> 

    <SurfaceView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/liveSurfaceView" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:nestedScrollingEnabled="false"/> 
</RelativeLayout> 

MainActivity.java

@Override 
    protected void onCreate(Bundle savedInstanceState) 
    { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
    setSupportActionBar(toolbar); 

    SurfaceView liveSurfaceView = (SurfaceView) findViewById(R.id.liveSurfaceView);  
    liveSurfaceView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION 
      | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 
      | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar 
      | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar 
      | View.SYSTEM_UI_FLAG_IMMERSIVE 
     ); 
    getSupportActionBar().hide(); 
    } 

Dieser Code funktioniert in Android-Geräten mit Kitkat (API 19). Aber wenn ich denselben Code auf Geräten mit Lollipop oder höher ausführe, ist die resultierende Anzeige wie folgt.

enter image description here

die uper und unteren Grenzen sind sichtbar und Surfacevollbild nicht abdeckt. Wie kann ich das beheben? Danke

Antwort

0

Das ist Beispiel !!!

<application android:allowBackup="true" 

    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name"  
    android:theme="@style/AppTheme.NoActionBar"> 
    <activity android:name=".MainActivity" android:label="@string/app_name" 
     android:screenOrientation="portrait"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 

</application> 

In style.xml

<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar"> 
    <item name="windowActionBar">false</item> 
    <item name="windowNoTitle">true</item> 
    <item name="android:windowFullscreen">true</item> 

</style> 
+0

wie in Lollipop und höher auf Vollbild? Systemleiste und Navigationsleiste sind weiterhin sichtbar. –

+0

Verwenden Sie Theme NoActiBar.FullScreen –

+0

@android: Stil/Theme.NoTitleBar.Fullscreen –

Verwandte Themen