欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Dialog全屏,去掉狀態(tài)欄的方式

 更新時(shí)間:2020年03月24日 10:59:24   作者:snowzhao210  
這篇文章主要介紹了Dialog全屏,去掉狀態(tài)欄的方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧

dialog即使設(shè)置全屏了,但還是有狀態(tài)欄占用高度這;

直接將下面這行代碼放到你的dialog中即可

 @Override
 protected void onStart() {
  super.onStart();
  int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
    | View.SYSTEM_UI_FLAG_IMMERSIVE
    | View.SYSTEM_UI_FLAG_FULLSCREEN;
  this.getWindow().getDecorView().setSystemUiVisibility(uiOptions);
 }

順便說(shuō)下自定義dialog寬高:

WindowManager.LayoutParams attributes = getWindow().getAttributes();
  attributes.width = width;
  attributes.height = height;
  getWindow().setAttributes(attributes);

添加兩個(gè)基本的style

 <!--普通dialog樣式-->
 <style name="customerDialog" parent="@android:style/Theme.Dialog">
  <item name="android:windowFrame">@null</item>
  <item name="android:windowIsFloating">true</item>
  <item name="android:windowIsTranslucent">true</item>
  <item name="android:windowNoTitle">true</item>
  <item name="android:background">@android:color/transparent</item>
  <!-- <item name="android:windowAnimationStyle">@android:style/Animation.Translucent</item> -->
  <item name="android:windowBackground">@android:color/transparent</item>
  <item name="android:windowSoftInputMode">stateHidden|adjustPan</item>
 </style>


 <!--透明背景dialog樣式-->
 <style name="TransparentDialogStyle" parent="@android:style/Theme.Dialog">
  <item name="android:windowBackground">@android:color/transparent</item>
  <item name="android:windowNoTitle">true</item>
  <item name="android:backgroundDimEnabled">false</item>
 </style>

補(bǔ)充知識(shí):Android關(guān)于全屏設(shè)置和隱藏狀態(tài)欄、沉浸式狀態(tài)欄的總結(jié)

1.全屏和推出全屏

實(shí)現(xiàn)全屏

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

有一個(gè)View.setLayoutparams的方法,注意這個(gè)LayoutParams跟的不是自身的LayoutParams而是父容器的layoutParams

退出全屏

final WindowManager.LayoutParams attrs = getWindow().getAttributes();
   attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
   getWindow().setAttributes(attrs);
   getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

2.隱藏狀態(tài)欄

getWindow().getDecorView().setSystemUiVisibility(View.INVISIBLE);

參數(shù):

View.SYSTEM_UI_FLAG_VISIBLE:顯示狀態(tài)欄,Activity不全屏顯示(恢復(fù)到有狀態(tài)的正常情況)。

View.INVISIBLE:隱藏狀態(tài)欄,同時(shí)Activity會(huì)伸展全屏顯示。

View.SYSTEM_UI_FLAG_FULLSCREEN:Activity全屏顯示,且狀態(tài)欄被隱藏覆蓋掉。

View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN:Activity全屏顯示,但狀態(tài)欄不會(huì)被隱藏覆蓋,狀態(tài)欄依然可見(jiàn),Activity頂端布局部分會(huì)被狀態(tài)遮住。

View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION:效果同View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

View.SYSTEM_UI_LAYOUT_FLAGS:效果同View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

View.SYSTEM_UI_FLAG_HIDE_NAVIGATION:隱藏虛擬按鍵(導(dǎo)航欄)。有些手機(jī)會(huì)用虛擬按鍵來(lái)代替物理按鍵。

View.SYSTEM_UI_FLAG_LOW_PROFILE:狀態(tài)欄顯示處于低能顯示狀態(tài)(low profile模式),狀態(tài)欄上一些圖標(biāo)顯示會(huì)被隱藏。

3.沉浸式狀態(tài)欄(android4.4開(kāi)始引進(jìn))

(1).通過(guò)SystemBarTintManager

 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
  setTranslucentStatus(true);
  SystemBarTintManager tintManager = new SystemBarTintManager(this);
  tintManager.setStatusBarTintEnabled(true);
  tintManager.setStatusBarTintResource(R.color.color_top_bg);// 通知欄所需顏色
  }

    @TargetApi(19)
 private void setTranslucentStatus(boolean on) {
 Window win = getWindow();
 WindowManager.LayoutParams winParams = win.getAttributes();
 final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
 // WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
 if (on) {
  winParams.flags |= bits;
 } else {
  winParams.flags &= ~bits;
 }
 win.setAttributes(winParams);
 }

(2).通過(guò)頂部增加同ActionBar顏色的view(如果設(shè)置后出現(xiàn)tittlebar則在清單文件里面配置activity的style為NoTittlebar)

 Window window = getWindow(); 
 window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
 ViewGroup decorView = (ViewGroup) window.getDecorView();
 view = new View(this);
 view.setLayoutParams(new ViewGroup.LayoutParams(
  ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight(this)));
 view.setBackgroundColor(getResources().getColor(R.color.color_top_bg));
 decorView.addView(view);

以上這篇Dialog全屏,去掉狀態(tài)欄的方式就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論