Android在代碼中設(shè)置沉浸式布局的方法
先導(dǎo)入該包,進(jìn)行 系統(tǒng)systemBar 管理
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
在BaseActivity中添加 該 字段;
public class BaseActivity extends Activity{ @Override protected void onCreate(Bundle savedInstanceState) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setTranslucentStatus(true); SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintResource(R.color.my_red);//通知欄所需顏色 } super.onCreate(savedInstanceState); this.activity = this; } @TargetApi(19) private 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); } }
以上所述是小編給大家介紹的Android在代碼中設(shè)置沉浸式布局的方法,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
- Android App仿QQ制作Material Design風(fēng)格沉浸式狀態(tài)欄
- Android實(shí)現(xiàn)沉浸式通知欄通知欄背景顏色跟隨app導(dǎo)航欄背景顏色而改變
- Android沉浸式狀態(tài)欄實(shí)現(xiàn)
- 另外兩種Android沉浸式狀態(tài)欄實(shí)現(xiàn)思路
- Android 實(shí)現(xiàn)沉浸式狀態(tài)欄的方法
- Android代碼實(shí)現(xiàn)圖片和文字上下布局
- android 線性布局LinearLayout實(shí)例代碼
- android LinearLayout 布局實(shí)例代碼
- android layout 按比例布局的代碼
相關(guān)文章
Android入門之Activity四種啟動(dòng)模式(standard、singleTop、singleTask、singl
當(dāng)應(yīng)用運(yùn)行起來后就會(huì)開啟一條線程,線程中會(huì)運(yùn)行一個(gè)任務(wù)棧,當(dāng)Activity實(shí)例創(chuàng)建后就會(huì)放入任務(wù)棧中。Activity啟動(dòng)模式的設(shè)置在AndroidManifest.xml文件中,通過配置Activity的屬性android:launchMode=""設(shè)置2015-12-12Android實(shí)現(xiàn)微信朋友圈評(píng)論EditText效果
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)微信朋友圈評(píng)論EditText效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-11-11Android實(shí)現(xiàn)button居中的方法
這篇文章主要介紹了Android實(shí)現(xiàn)button居中的方法,涉及Android的XML布局技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-09-09Android開發(fā)之ContentProvider的使用詳解
本篇文章介紹了Android開發(fā)之ContentProvider的使用詳解。需要的朋友參考下2013-04-04