Android 4.4沉浸式状态栏的实现
生活随笔
收集整理的這篇文章主要介紹了
Android 4.4沉浸式状态栏的实现
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
?
要實(shí)現(xiàn)Android 4.4上面的沉浸式狀態(tài)欄要用到開源項(xiàng)目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" :設(shè)置應(yīng)用布局時(shí)是否考慮系統(tǒng)窗口布局;如果為true,將調(diào)整系統(tǒng)窗口布局以適應(yīng)你自定義的布局。比如系統(tǒng)有狀態(tài)欄,應(yīng)用也有狀態(tài)欄時(shí)。 android:clipToPadding="true" : 屬性定義了是否允許ViewGroup在padding中繪制,該值默認(rèn)為true,即不允許。效果如下:
轉(zhuǎn)載于:https://www.cnblogs.com/l2rf/p/4766733.html
總結(jié)
以上是生活随笔為你收集整理的Android 4.4沉浸式状态栏的实现的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: iOS开发——高级技术地图功能的实现
- 下一篇: matlab mod()rem()