0
當我點擊一個按鈕,我必須設置我的活動全屏。 在互聯網上搜索我發現這樣做的代碼。全屏android
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);
但我做錯了什麼,因爲狀態欄和導航欄消失,我的活動拉曼高度相同。
這是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? 感謝
我已經嘗試過此操作,並且工作正常,但它不隱藏導航欄 –
嘗試編輯的代碼。這也刪除了標題欄。 – Fuzzie