我一直在阅读有关此问题的所有问题,但我仍然无法使操作栏中文字的颜色发生变化。对于代码我几乎复制/粘贴以下链接上的说明: https://developer.android.com/training/basics/actionbar/styling.html#CustomText
<!--theme applied to the application or activity-->
<style name="myActionbarTheme" parent="android:Theme.Holo">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<item name="android:actionBarTabTextStyle">@style/MyActionBarTabText</item>
<item name="android:actionMenuTextColor">@color/lightBlue</item>
</style>
<!-- actionBar styles -->
<style name="MyActionBar" parent="android:Widget.Holo.ActionBar">
<item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
</style>
<!-- actionBar title text -->
<style name="MyActionBarTitleText" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">@color/lightBlue</item>
<item name="android:textSize">16sp</item>
</style>
<!-- actionBar tabs text styles -->
<style name="MyActionBarTabText" parent="android:Widget.Holo.ActionBar.TabText">
<item name="android:textColor">@color/lightBlue</item>
</style>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
最后2种样式未使用,但它们可能会造成我不知道的冲突。这就是我在styles.xml中的内容,而对于androidmanifest,代码是:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.flexenergy.swapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo.Light" >
<activity
android:name="com.flexenergy.swapp.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<application
android:allowBackup="true"
android:theme="@style/myActionBarTheme">
</application>
最后一个是color.xml的代码:
<item name="lightBlue" type="color">#00FF00</item>
<integer-array name="androidcolors">
<item>@color/lightBlue</item>
</integer-array>
我是一个相当新手,所以不要做任何正确的假设...
提前致谢。
答案 0 :(得分:2)
将您的清单中的android:theme="@android:style/Theme.Holo.Light"
更改为android:theme="@style/myActionbarTheme"
,并摆脱毫无意义的第二个<application>
元素。目前每个Android清单只有一个<application>
元素。