Change Action Bar Title color

后端 未结 8 1660
南笙
南笙 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:23

    If you want to change the ActionBar title color just follow this first. Go to style.xml and use the following code inside resources

    <style name="ActionBar.Solid.Ribbit.TitleTextStyle"
        parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
        <item name="android:textColor">@color/actionBarTextColor</item>
    </style>
    
    0 讨论(0)
  • 2020-12-04 22:27

    Simplest way that worked for me is to add the following in theme style:

    <item name="android:textColorPrimary">@color/orange_dark</item>
    
    0 讨论(0)
  • 2020-12-04 22:37

    i have changed title color like this

    actionBar.setTitle(Html.fromHtml("<font color='#ff0000'>ActionBarTitle </font>"));
    
    0 讨论(0)
  • 2020-12-04 22:39

    Use below code to provide different color to actionbar text and actionbar background just use below theme in manifest against the activity in which you want output :)

     <style name="MyTheme" parent="@android:style/Theme.Holo.Light">
            <item name="android:actionBarStyle">@style/MyActionBar</item>
        </style>
    
        <style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
            <item name="android:titleTextStyle">@style/TitleBarTextColor</item>
            <item name="android:background">YOUR_COLOR_CODE</item>
        </style>
    
        <style name="TitleBarTextColor" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
            <item name="android:textColor">YOUR_COLOR_CODE</item>
        </style>
    
    0 讨论(0)
  • 2020-12-04 22:42

    If you are trying to change the title text where you have a custom toolbar then try adding app:titleTextColor to the toolbar as below:

     <android.support.v7.widget.Toolbar
            android:id="@+id/my_toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            android:elevation="4dp"
            android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:titleTextColor="@color/colorWhite" />
    
    0 讨论(0)
  • 2020-12-04 22:43

    From Jake Wharton's ActionBarSherlock site :

    Mirrored Attributes

    Due to limitations in Android's theming system any theme customizations must be declared in two attributes. The normal android-prefixed attributes apply the theme to the native action bar and the unprefixed attributes are for the custom implementation.

    Had to change MyTheme.ActionBarStyle to :

       <style name="MyTheme.ActionBarStyle" parent="@style/Widget.Sherlock.ActionBar">
         <item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
         <item name="titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
       </style>
    

    Now the Title text color has changed.

    0 讨论(0)
提交回复
热议问题