2016-04-22 4 views
0

Когда я нажимаю кнопку, мне нужно настроить действие в полноэкранном режиме. Поиск в Интернете Я нашел код для этого.Полноэкранный андроид

container.setSystemUiVisibility(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 // hide nav bar 
           | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar 
           | View.SYSTEM_UI_FLAG_IMMERSIVE); 

Но я делаю что-то не так, потому что строка состояния и панель навигации исчезают, а моя активность растет с одинаковой высотой.

before

after

Это video.xml

<?xml version="1.0" encoding="utf-8"?>        
<android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true"         
    tools:context=".VideoActivity">         

    <include layout="@layout/content_video" />      

    <android.support.design.widget.FloatingActionButton    
     android:id="@+id/close"          
     android:layout_width="wrap_content"       
     android:layout_height="wrap_content"       
     android:layout_gravity="bottom|center_horizontal"    
     android:layout_marginBottom="70dp"       
     android:layout_marginRight="80dp"        
     android:src="@drawable/phone"         
     app:elevation="0dp"           
     app:backgroundTint="#44FF0000" />        

    <android.support.design.widget.FloatingActionButton    
     android:id="@+id/screen"          
     android:layout_width="wrap_content"       
     android:layout_height="wrap_content"       
     android:layout_gravity="bottom|center_horizontal"    
     android:layout_marginBottom="70dp"       
     android:layout_marginLeft="80dp"        
     android:src="@drawable/fullscreen"       
     app:elevation="0dp"           
     app:backgroundTint="#44000000"/>        

</android.support.design.widget.CoordinatorLayout> 

И это content_video.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" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context=".VideoActivity" 
    tools:showIn="@layout/video" 
    android:id="@+id/layout" 
    android:orientation="horizontal"> 

    <RelativeLayout 
     android:id="@+id/container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="#000000"> 
    </RelativeLayout> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:text="@string/string_video_id" 
     android:id="@+id/conference_id" 
     android:textColor="@android:color/white" 
     android:enabled="false" 
     android:focusable="false" 
     android:alpha="0.5" 
     android:background="@color/button_background" 
     android:paddingLeft="10dip" 
     android:paddingTop="5dip" 
     android:paddingRight="10dip" 
     android:paddingBottom="5dip" 
     android:layout_marginBottom="20dp" 
     android:layout_marginLeft="10dp" 
     android:gravity="bottom" 
     android:layout_alignParentBottom="true"/> 

</RelativeLayout> 

Может кто-то помочь мне Plase? Благодаря

ответ

0

Там может быть лучше на это делать, но самым простым способом я использую,

// Fullscreen 
    requestWindowFeature(Window.FEATURE_NO_TITLE); 
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 

Я положил это в классе активности.

+0

Я пробовал это раньше и прекрасно работает, но не скрывает навигационную панель –

+0

Попробуйте отредактированный код. Это также удаляет строку заголовка. – Fuzzie

Смежные вопросы