Change Action Bar Title color

后端 未结 8 1653
南笙
南笙 2020-12-04 21:57

My code is as below and while it works ( when I change the parent Theme to Theme.Sherlock or Theme.Sherlock.Light the Theme it does changes) it does not changes the Title co

相关标签:
8条回答
  • 2020-12-04 22:46

    in your style.xml in values folder this will change your action bar color.. Replace #666666 with your selected color code for title background color and replace #000000 for your title text color.

    <style name="MyTheme" parent="@android:style/Theme.Holo.Light">
        <item name="android:actionBarStyle">@style/NewActionBar</item>
    </style>
    
    <style name="NewActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:titleTextStyle">@style/TitleBarTextColor</item>
    <item name="android:background">#666666</item>
    </style>
    <style name="TitleBarTextColor" parent="@style/TextAppearance.Sherlock.Widget.ActionBar.Menu">
        <item name="android:textColor">#000000</item>
    </style>
    

    then dont forget to edit your manifest file -> android:theme="@style/NewTheme"

        <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/NewTheme" >
        <activity
            android:name="com.nearby.welcome.Splash"
            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>
    
    0 讨论(0)
  • 2020-12-04 22:47

    I tried all the above methods, it does n't worked for me.I have just achieved through code below..

    Spannable text = new SpannableString(actionBar.getTitle());
    text.setSpan(new ForegroundColorSpan(Color.BLUE), 0, text.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
    actionBar.setTitle(text);
    
    0 讨论(0)
提交回复
热议问题