日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

Android 4.4沉浸式状态栏的实现

發布時間:2025/7/14 Android 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Android 4.4沉浸式状态栏的实现 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?

要實現Android 4.4上面的沉浸式狀態欄要用到開源項目SystemBarTint(https://github.com/hexiaochun/SystemBarTint)

?

public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {setTranslucentStatus(true);}SystemBarTintManager tintManager = new SystemBarTintManager(this);tintManager.setStatusBarTintEnabled(true);tintManager.setStatusBarTintResource(R.drawable.back);}@TargetApi(19)public void setTranslucentStatus(boolean on) {Window win = getWindow();WindowManager.LayoutParams winParams = win.getAttributes();final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;if (on) {winParams.flags |= bits;} else {winParams.flags &= ~bits;}win.setAttributes(winParams);}

?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" android:clipToPadding="true" android:background="#ffffff" android:orientation="vertical" > <TextView android:layout_width="match_parent" android:layout_height="100dp" android:background="#009959" /> <Button android:layout_width="100dp" android:layout_height="50dp" android:background="#ff669d"/> </LinearLayout>

?

android:fitsSystemWindows="true" :設置應用布局時是否考慮系統窗口布局;如果為true,將調整系統窗口布局以適應你自定義的布局。比如系統有狀態欄,應用也有狀態欄時。 android:clipToPadding="true" : 屬性定義了是否允許ViewGroup在padding中繪制,該值默認為true,即不允許。


效果如下:





轉載于:https://www.cnblogs.com/l2rf/p/4766733.html

總結

以上是生活随笔為你收集整理的Android 4.4沉浸式状态栏的实现的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。