style:
<resources xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Application theme. --> <style name="AppTheme" parent="android:Theme.Holo.Light"> <item name="android:actionBarStyle">@style/MyActionBar </item> </style> <style name="MyActionBar" parent="@android:style/Widget.Holo.ActionBar"> <item name="android:titleTextStyle">@style/TextAppearance.Holo.Widget.ActionBar.Title.Own</item> </style> <style name="TextAppearance.Holo.Widget.ActionBar.Title.Own" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title"> <item name="android:textColor">#66CC00</item> </style> </resources>
http://www.cnblogs.com/xiaobo-Linux/ 赵存档QQ463431476
AndroidManifest.xml中将应用的主题设置成自己定义的一个继承了Theme.Holo.Light的主题。
1 2 3 4 5class="js plain" style="background: none !important; margin: 0px !important; padding: 0px !important; outline: 0px !important; border-radius: 0px !important; border: 0px currentColor !important; left: auto !important; top: auto !important; width: auto !important; height: auto !important; text-align: left !important; right: auto !important; bottom: auto !important; color: #000000 !important; line-height: 1.1em !important; overflow: visible !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; vertical-align: baseline !important; float: none !important; white-space: pre-wrap; position: static !important; min-height: inherit !important; box-sizing: content-box !important;"><application
android:allowBackup=
"true"
android:icon=
"@drawable/ic_launcher"
android:label=
"@string/app_name"
android:theme=
"@style/CustomActivityTheme"
>
在res/values/的style文件中,我只是想改变这个主题的应用标题,所以只需自定义一下actionbar的样式:
1 2 3 4<style name=
"CustomActivityTheme"
parent=
"@android:style/Theme.Holo.Light"
>
<item name=
"android:actionBarStyle"
>@style/MyActionBar</item>
</style>
@style/MyActionBar,MyActionBar
就是我们自定义样式的名称,写法如下:
<style name=
"MyActionBar"
parent=
"@android:style/Widget.Holo.ActionBar"
>
<item name=
"android:titleTextStyle"
>@style/TextAppearance.Holo.Widget.ActionBar.Title.Own</item>
</style>
android:titleTextStyle属性是ActionBar的属性之一,设置actionbar字体颜色的,而titleTextStyle的属性又有好多种,因此我们又定义了一个自定义的style TextAppearance.Holo.Widget.ActionBar.Title.Own来设置titleTextStyle
1 2 3 4<style name=
"TextAppearance.Holo.Widget.ActionBar.Title.Own"
parent=
"@android:style/TextAppearance.Holo.Widget.ActionBar.Title"
>
<item name=
"android:textColor"
>
#FFFFFF</item>
</style>
如此这般设置之后,我的目的就达到了,这次我得到的经验是,任何主题都是可以随意定制的,但是你必须清楚,每个主题之下有哪些属性,他们的作用和名称。否则你还是没办法。