自定义一个Theme

来源:互联网 发布:3d效果图软件 编辑:程序博客网 时间:2024/06/08 08:00
1. 继承已有Theme(不然写的属性就太多了)
在自己的某个style.xml或者theme.xml中加上
<style name = "Theme_Custom" parent="@*android:style/Theme.Holo.Light"><item name = "android:listChoiceBackgroundIndicator">@drawalbe/custom_list_selector_holo_light></item><item name = "android:actionBarStyle">@style/CustomActonbar></item></style>
以上自定义list的背景色:custom_list_selector_holo_light

2.实现具体的属性
1). custom_list_selector_holo_light.xml是放在res/drawable/下,可以指定一个随点击或者按下产生不同效果的图片,
<selector xmlns:android=""http://schemas.android.com/apk/res/android"><item android:state_pressed="true" android:drawable="@drawable/wind_list_focused"/><item android:state_focused="true"android:state_enable="true" android:drawable="@drawable/wind_list_focused"/></selector>
wind_list_focused.9.png就是一张9patch的文件了。


2). @style/CustomActonbar是自己写的style
修改/res/values/style.xml
<style name="WindCustomTitleTextColor" parent="@*android:style/TextAppearance.Holo.Widget.ActionBar.Title"><item name = "android:textColor">@*android:color/white</item></style><style name="WindCustomActionbar" parent="@*android:style/Widget.Holo.Light.ActionBar.Solid"><item name = "android:background">@drawalbe/wind_titlebar_background></item><item name = "android:titleTextStyle">@style/WindCustomTitleTextColor></item></style>

上面的两个属性是自定义ActionBar的背景色:wind_titlebar_background.png和字体颜:@*android:color/white
wind_titlebar_background.png为ActionBar的背景图片
原创粉丝点击