安卓默认的标题栏黑乎乎非常难看。不过可以通过theme来自定义标题栏样式。
在一次项目中需要把颜色修改为蓝色,高度40dp,标题文字居中的效果,不过网上没有搜到好的解决方法,又不想用自定义标题栏。所以把自己想出来的方法记下来。
步骤如下:
1.首先在values文件夹下创建colors.xml文件,内容如下:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android" >
<color name="blue">#ff004B97</color>
</resources>
2.在styles.xml文件中添加以下代码:
<style name="CustomTextApperance" >
<item name="android:textColor">#fff</item>
<item name="android:textSize">18sp</item>
<item name="android:textStyle">bold</item>
</style>
<style name="CustomWindowTitle" parent="*andr