Question

I need to use theme in my app.

Some of the TextView has a specific color for text coming from styles.xml:

<TextView
    android:id="@+id/menuItemText"
    style="@style/main_menu_item_text" />

styles.xml:

<style name="main_menu_item_text">
    <item name="android:textColor">@color/theme_color</item>
</style>

Now, theme_color is blue for Theme1, is red for Theme2. How can I do?

I don't want to change the default text color but only the color theme_color.

Was it helpful?

Solution

If you want to override Android default themes, first make sure you can target the correct platform - the themes have changed.

Second, you can override one property this way:

Override default Android themes

Third, if you just wanted it done for an activity, you can apply the theme for the activity in the manifest.

Or, if you are just looking to override the color only, you can always add the line:

android:textColor="@color/theme_color"

to each textview you want to appear that way (it will override the style)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top