Override text color for buttons not working

I created a custom theme for the button bar using buttonBarStyle on each button and buttonBarButtonStyle on the layout. It works fine, but I want to change the text color for the buttons, but it still accepts the default color (@android: color / primary_text_holo_light) My code is:

<style name="ButtonBarTheme" parent="AppTheme">
        <item name="buttonBarStyle">?android:attr/buttonBarStyle</item>
        <item name="buttonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
        <item name="android:textColor">#ffffff</item>
</style>

And for the layout:

<LinearLayout 
    style="?android:attr/buttonBarStyle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#0090cc"
    android:orientation="horizontal" >

    <Button
        android:id="@+id/bar_button1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        style="@style/ButtonBarStyleButton"
        android:text="Button 1" />

    <Button
        android:id="@+id/bar_button2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        style="?android:attr/buttonBarButtonStyle"
        android:text="Button 2" />

</LinearLayout>

AppTheme has a parent AppBaseTheme that has a parent android: Theme.Holo.Light.DarkActionBar.

What do I need to do to change the color of the button text?

EDIT: I tried applying color to each element and it works, but I want to change it by overriding the color in the style file (keep all design properties in one place, similar to CSS).

, , ? android: attr/buttonBarStyle "

   <style name="ButtonBarStyleButtonBase">
        <item name="buttonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
    </style>

   <style name="ButtonBarStyleButton" parent="ButtonBarStyleButtonBase">
        <item name="android:textColor">#ffFFff</item>
    </style>

: , , , .

+4
2

, , , . Android , , , /.

, , . . , , /, ( ).

, , buttonBarStyle buttonBarButtonStyle, Activity . Activity, , .

, , , , View Style .

<style name="CustomButtonStyle" parent="@android:attr/buttonStyle">
        <item name="android:textColor">#ffffff</item>
</style>


<style name="AppTheme" parent="@android:style/Theme.Holo.Light.DarkActionBar">
        <item name="buttonStyle">@style/CustomButtonStyle</item>
</style>


<application
    ...
    android:theme="@style/AppTheme" >

.

, ButtonBar Style, , ButtonBar Style . , . , :

<style name="CustomButtonBarStyle" parent="@android:attr/buttonBarStyle">
        <item name="android:textColor">#ffffff</item>
</style>


<style name="AppTheme" parent="@android:style/Theme.Holo.Light.DarkActionBar">
        <item name="buttonBarStyle">@style/CustomButtonBarStyle</item>
</style>


<application
    ...
    android:theme="@style/AppTheme" >

ButtonBar, :

<Button
        ...
        style="?android:attr/buttonBarStyle"/>

, ButtonBar, (, Activity, ). , , , , - , .

+4

, , . (: attr/buttonBarStyle, ) .

buttonBarStyle - : attr/buttonBarStyle , :

android:background="?android:attr/selectableItemBackground"

:

android:textColor="@color/your_color"

buttonBarButtonStyle.

0

Source: https://habr.com/ru/post/1525120/


All Articles