locked
How to make TextViews have the same color as ActionBar without applying styles to them? RRS feed

  • Question

  • User337237 posted

    Is there any way to set Action Bar color and that color to apply also to all TextViews's text propery of the entire application without creating a style for all the TextViews and applying it to them?

    Thursday, December 5, 2019 10:48 AM

Answers

  • User379860 posted

    If you want to set text color for all of Textview, you could open your styles.xml, found <item name="colorPrimary">@color/colorPrimary</item> this item, and add <item name="android:textColor">@color/colorPrimary</item> like following code.

      <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>
    
      <item name="android:textColor">@color/colorPrimary</item>
    </style>
    

    After that, all the text will be setted.

    If you do not want to do that, you should create style in styles.xml

       <style name="TextColor">
          <item name="android:textColor">@color/colorPrimary</item>
       </style>
    

    Apply it to all textview.

        <TextView
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           style="@style/TextColor"
           android:text="@string/abc_action_bar_home_description"/>
    
    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, December 5, 2019 1:03 PM