记一次Android完整项目(1)-设置statusBar颜色
16lz
2021-01-26
一.statysBar颜色设置方法
方法一:
在styles.xml里设置"colorPrimaryDark"的值:
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimaryDark">@color/mainColor</item> </style></resources>
方法二:
在styles.xml里设置"statusBarColor"的值:
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="android:statusBarColor">@android:color/black</item> </style></resources>
二.colorPrimaryDark和statusBarColor
不同点:
-1.statusBarColor具有更高的优先级,两个同时出现,statusBarColor会覆盖colorPrimaryDark。
-2.statusBarColor在Android5.0以下的版本中会出现警告。
-3.默认情况下,statusBarColor的值继承自colorPrimaryDark。
更多相关文章
- [置顶] Android(安卓)ButterKnife
- android webview 介绍
- android 快速开发(三)巧用公共标题栏:避免每次activity都得写标题栏
- Android中间层c语言log打印方法
- Android设置程序最小运行的堆内存
- Android(安卓)studio从菜鸟到高手--第一季
- android UI进阶之自定义组合控件
- android NumberPicker 全面解析
- Android使用HttpURLConnection进行POST请求,向服务器上传数据