1.在Android多個(gè)系統(tǒng)版本兼容的情況下,選擇一款合適的方案做通知欄時(shí)很關(guān)鍵的击纬,話不多說(shuō)直接上三方庫(kù)https://github.com/gyf-dev/ImmersionBar
2.問題一般我們?cè)O(shè)置是在基類中的OnCreate方法聲明捉腥,在OnDestory方法中銷毀七问,但是有的時(shí)候頁(yè)面需要沉浸式营勤,或者不一樣的通知欄,之前我也覺得是直接在子類Activity中再聲明一遍不就OK了锋华,結(jié)果沒個(gè)卵用
用法:
創(chuàng)建
ImmersionBar.with(this)
.statusBarColor(R.color.transparent) //狀態(tài)欄顏色,不寫默認(rèn)透明色
.statusBarDarkFont(true) //原理:如果當(dāng)前設(shè)備支持狀態(tài)欄字體變色箭窜,會(huì)設(shè)置狀態(tài)欄字體為黑色毯焕,如果當(dāng)前設(shè)備不支持
狀態(tài)欄字體變色,會(huì)使當(dāng)前狀態(tài)欄加上透明度磺樱,否則不執(zhí)行透明度
.fitsSystemWindows(true)
.keyboardEnable(true)
.navigationBarColor(R.color.virtual_buttons)
.init();
銷毀
ImmersionBar.with(this).destroy();
3.加入子類activity要沉浸式代碼怎么辦呢
-在oncreat方法中先銷毀
ImmersionBar.with(this).destroy();
ImmersionBar.with(this)
.titleBar(null, false)
//.transparentBar()
.statusBarDarkFont(true)
//.fullScreen(true)
.navigationBarColor(R.color.virtual_buttons)
.init();
-接著在onDestroy()中銷毀
ImmersionBar.with(this).destroy();
4.這樣就行了纳猫,如果需要更炫酷的用法就去看看文檔和demo,很實(shí)用