2016-04-28 103 views
0

我創建了這樣的surfaceView。FullScreen for SurfaceView不工作在棒棒糖或更高版本

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(); 
    } 

這個代碼在運行奇巧(API 19)機器人裝置。但是當我在運行棒棒糖或更高版本的設備上運行相同的代碼時,結果顯示如下所示。

enter image description here

的UPER,下邊框是可見的,surfaceView不包括全屏。我怎樣才能解決這個問題?謝謝

回答

0

這是實例!!!

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

添加到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

如何棒棒糖和更高的全屏?因爲系統欄和導航欄仍然可見。 –

+0

使用主題NoActiBar.FullScreen –

+0

@android:style/Theme.NoTitleBar.Fullscreen –

相關問題