I want to change the color of the text of my Actio

2019-09-02 05:08发布

问题:

I'm not able to change the color of the text of the action bar, the color of the background is working fine, but not the color of the text.

     <style name="MyTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
    <item name="android:titleTextStyle">@style/myTheme.ActionBar.Text</item>
</style>

<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:background">#0E2F44</item>
</style>

  <style name="myTheme.ActionBar.Text" parent="@android:style/TextAppearance">
    <item name="android:textColor">@color/actionBarText</item>
</style>

here is the manifest :

 <uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="21" />

回答1:

why don't you do it programmatically

Random rnd = new Random(); 
ToolBar.setTitleTextColor(Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)));

actually this set's a random colour..