Android 沉浸式statusbar (5.0以上无阴影,statusbar背景全透明)
2016-11-10 17:50
429 查看
1.android:fitsSystemWindows="true"
只能配置在Activity,使自定义布局能占据statusbar
2.如果是继承了AppCompatActivity
在manifests设置
3.如果希望状态栏没有阴影,背景颜色自定义在Activity中加:
4.如果希望状态栏没有阴影,像qq空间 动态 页面,状态栏 直接 是 一张背景图片在Activity中加:
必须去掉布局的android:fitsSystemWindows="true"
gethub地址:https://github.com/freesky12138/StatusBar
只能配置在Activity,使自定义布局能占据statusbar
2.如果是继承了AppCompatActivity
在manifests设置
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
3.如果希望状态栏没有阴影,背景颜色自定义在Activity中加:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setTranslucentStatus(true); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.parseColor("#4cb86a")); window.setNavigationBarColor(Color.TRANSPARENT); } else { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintResource(R.color.colorPrimary);//通知栏所需颜色*/ }
@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); }
4.如果希望状态栏没有阴影,像qq空间 动态 页面,状态栏 直接 是 一张背景图片在Activity中加:
必须去掉布局的android:fitsSystemWindows="true"
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setTranslucentStatus(true); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); window.addFl 4000 ags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.TRANSPARENT); window.setNavigationBarColor(Color.TRANSPARENT); }else { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintColor(Color.TRANSPARENT); }
gethub地址:https://github.com/freesky12138/StatusBar
相关文章推荐
- android 5.0及以上,seekbar thumb 透明效果出现父布局背景颜色的解决方法
- android 5.0及以上,seekbar thumb 透明效果出现父布局背景颜色的解决方法
- android 5.0 statusbar状态栏透明 解决方案
- 使用as开发Android 5.0以上版本去掉Button自带阴影效果的方法
- android 自定义 ProgressDialog 在5.0以上出现白色背景的解决方法
- Android 5.0以上实现透明状态栏
- Android 5.0及以上系统实现沉浸式状态栏
- 解决Android 5.0以上版本Button自带阴影效果的方法
- Android_5.0定制--------在Launcher界面改变SystemUI中的NavigationBar和StatusBar背景颜色
- (转)解决Android 5.0以上版本Button自带阴影效果的方法
- 解决Android 5.0以上版本Button自带阴影效果的方法
- 解决Android 5.0以上Button自带阴影的问题
- Android 5.0 StatusBar全透明
- Android之高仿QQ6.6.0侧滑效果(背景动画、透明+沉浸式状态栏、渐变效果)
- Android 沉浸式状态栏(QQ5.0透明状态栏的效果)
- Android 改变statusbar背景-沉浸式状态栏与导航栏
- 解决android 5.0 dialog背景无法透明的问题
- android开发(50) Android透明状态栏。适用于 4.4 以上及 5.0以上设备
- Android 4.4 以及 5.0以上 透明状态栏
- Android 5.0以上Button去掉阴影