72、android状态栏一体化,状态栏改变颜色
生活随笔
收集整理的這篇文章主要介紹了
72、android状态栏一体化,状态栏改变颜色
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
? ? ?只能在4.4以上版本使用。
?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:background="#6699ff"android:clipToPadding="true"android:fitsSystemWindows="true"android:orientation="vertical" ><RelativeLayoutandroid:layout_width="fill_parent"android:layout_height="50dp"android:orientation="vertical" ><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:text="標(biāo)題"android:textColor="#ffffff"android:textSize="20sp" /></RelativeLayout><LinearLayoutandroid:layout_width="fill_parent"android:layout_height="fill_parent"android:background="#ffffff"android:gravity="center"android:orientation="vertical" ><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Hello World"android:textColor="#000000"android:textSize="28sp"android:textStyle="italic" /></LinearLayout></LinearLayout>?
android:clipToPadding="true"clipToPadding:控件的繪制區(qū)域是否在padding里面, 值為true時(shí)padding那么繪制的區(qū)域就不包括padding區(qū)域;?
android:fitsSystemWindows="true" 設(shè)置應(yīng)用布局時(shí)是否考慮系統(tǒng)窗口布局;如果為true,將調(diào)整系統(tǒng)窗口布局以適應(yīng)你自定義的布局。比如系統(tǒng)有狀態(tài)欄,應(yīng)用也有狀態(tài)欄時(shí)。
看你這個(gè)布局代碼,恰恰是在定義標(biāo)題欄樣式,所以用到這行代碼了。
@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);//判斷當(dāng)前SDK版本號(hào),如果是4.4以上,就是支持沉浸式狀態(tài)欄的if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);}}
?
?
總結(jié)
以上是生活随笔為你收集整理的72、android状态栏一体化,状态栏改变颜色的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: ajax查询数据的举例
- 下一篇: iOS中 动态启动图GIF的简单设置 韩