androidの4.4版本沉浸式透明状态栏与导航栏案例
来源:互联网 发布:2017个人博客源码下载 编辑:程序博客网 时间:2024/05/21 17:05
androidの4.4版本沉浸式透明状态栏与导航栏案例
1. Android 系统自4.2 开始 UI 上就没多大改变,4.4 也只是增加了透明状态栏与导航栏的功能,如图
看上去的确很好看样子,,接下来看看操作步骤:
protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_match_actionbar);if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {setTranslucentStatus(true);}SystemBarTintManager tintManager = new SystemBarTintManager(this);tintManager.setStatusBarTintEnabled(true);tintManager.setStatusBarTintResource(R.color.statusbar_bg2);}我们看到在oncreate 方法中,布局xml 不做更改。
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
setTranslucentStatus(true);
}
setTranslucentStatus(true);
}
这里是更改的状态栏里透明的;调用方法setTranslucentStatus(true);
@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);}
然后看到下面有
SystemBarTintManager tintManager = new SystemBarTintManager(this);
tintManager.setStatusBarTintEnabled(true);
tintManager.setStatusBarTintResource(R.color.statusbar_bg2);
这里有个设置颜色值,即为当前状态栏的颜色。
tintManager.setStatusBarTintEnabled(true);
tintManager.setStatusBarTintResource(R.color.statusbar_bg2);
这里有个设置颜色值,即为当前状态栏的颜色。
那么更改了状态栏颜色值后, Actionbar颜色值也要变化啊,,,不急,继续下面更改actionbar颜色
在主配置文件中,
android:theme="@style/ActionBarTheme"
然后定义该样式即可
<style name="ActionBarTheme" parent="android:Theme.Holo.Light.DarkActionBar"> <!-- API 14 theme customizations can go here. --> <item name="android:actionBarStyle">@style/ActionBarStyle</item> </style> <style name="ActionBarStyle" parent="android:Widget.Holo.Light.ActionBar.Solid.Inverse"> <item name="android:background">@color/actionbar_bg</item> </style>这里background就是actionbar 颜色值啦。。。
以上就实现了完整更改。。。源码群里奉上。。
欢迎进入android 学习群:191974931
0 0
- androidの4.4版本沉浸式透明状态栏与导航栏案例
- Android 4.4 沉浸式透明状态栏与导航栏
- Android 4.4 沉浸式透明状态栏与导航栏
- Android 4.4 沉浸式透明状态栏与导航栏
- Android 沉浸式透明状态栏与导航栏
- 沉浸式透明状态栏与导航栏
- Android 4.4 沉浸式透明状态栏与导航栏,android4.4
- Android 4.4 沉浸式透明状态栏与导航栏,android4.4
- Android状态栏和导航栏透明和沉浸式模式
- 对系统版本为4.4及以上的开启 透明状态栏和导航栏(即沉浸式状态栏)
- 改变、透明状态栏和导航栏颜色 (沉浸式状态栏)
- android 透明状态栏与沉浸式
- Android 沉浸式布局与透明状态栏
- Android 4.4 沉浸式透明状态栏
- Android 改变statusbar背景-沉浸式状态栏与导航栏
- Android 沉浸式状态栏与隐藏导航栏
- Android沉浸式状态栏5.0版本及透明状态栏兼容4.4
- 透明状态栏与沉浸式
- 招聘行业还有机会吗?
- Coursera-Machine Learning 笔记(一)
- CentOS 7在线安装MySQL
- Hadoop分布式集群搭建(一)创建hadoop用户、配置ssh、安装jdk
- ABAP 根据阳历日期获得阴历日期
- androidの4.4版本沉浸式透明状态栏与导航栏案例
- REST 表征性状态传输
- top命令详解
- jquery ajaxfileupload插件实现文件上传
- 四,java语言安全
- Mac OSX 下使用pythonbrew安装zlib 报ImportError: No module named 'zlib' 解决方案
- 【JNI】jni.h函数详解手册--The Java(TM) Native Interface
- MYSQL性能调优
- 黑马程序员_OC面向对象的特性