3

Hello I need help on changing the text color of the action Bar the following is my style.xml.I need to change the text color to white including the settings icon.

    <resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" >

    </style>
    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>

The String.xml source codes are as follows.

<resources>
    <string name="app_name">yebo</string>

    <string name="navigation_drawer_open">Open navigation drawer</string>
    <string name="navigation_drawer_close">Close navigation drawer</string>

    <string name="action_settings">Settings</string>

</resources>
user3551487
  • 162
  • 2
  • 3
  • 15

4 Answers4

3

Change in your style.

 <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

Add underneath line:

    <item name="actionMenuTextColor">Your Color Here</item>
    <item name="textColorPrimary">Your Color Here</item>
</style>

Hope it helps.

Dhruv
  • 1,801
  • 1
  • 15
  • 27
Jay Rathod
  • 11,131
  • 6
  • 34
  • 58
  • textColorPrimary will then change the text color in other places, such as the overflow popup menu – Terry W Feb 18 '20 at 17:11
1

You can simply put color to your strings like this:

<string name="app_name"><![CDATA[<b><font color=#FFFFFF>yebo</b>]]></string>
usamazf
  • 3,195
  • 4
  • 22
  • 40
0

In your .axml put a RelativeLayout to add the actionbar. In here add a TextView with the property android:textColor="#FFFFFF". (#FFFFFF is white). As such:

<RelativeLayout
    android:id="@+id/titleBarLinearLayoutFrontPage"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="55dp"
    android:background="#696969">
    <TextView
        android:textColor="#FFFFFF"
        android:id="@+id/txtActionBarText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="My Action Bar"
        android:layout_gravity="center"
        android:clickable="true"
        android:layout_centerVertical="true"
        android:textSize="22dp"
        android:layout_alignParentLeft="true"
        android:layout_marginLeft="60dp"
        android:layout_centerHorizontal="true" />
</RelativeLayout>
ToFo
  • 1,643
  • 1
  • 19
  • 34
-1

Valus/styles.xml uses colors.xml file. When you press "control" and click @color/colorPrimary it shows you where colorPrimary comes. Which is colors.xml. In your colors.xml file you can edit it.

Colors.xml

When you click the colour on the left it opens color palette. And you can change it easily. Color palette

emin deniz
  • 439
  • 5
  • 13