0

How can i change the text color of all the button in my app ? right now the only think that work is to do :

  <style name="MyTheme" parent="@android:style/Theme.Material.Light.NoActionBar"> 

    <item name="android:textColor">#ff0000</item>

  </style>

but i m a little worried to use android:textColor who seam to not only impact the button

I try this but it's didn't work :

  <style name="BBButtonColor" parent="@android:style/Widget.Button">
    <item name="android:textColor">#ff0000</item>
  </style> 

  <style name="BBButtonStyle" parent="@android:style/Widget.Button">
    <item name="android:textColor">#ff0000</item>
  </style> 

  <style name="BBBorderlessButtonStyle" parent="@android:style/Widget.Button">
    <item name="android:textColor">#ff0000</item>
  </style> 


  <style name="MyTheme" parent="@android:style/Theme.Material.Light.NoActionBar"> 

    <item name="android:textAppearanceButton">@style/BBButtonColor</item> 
    <item name="android:buttonStyle">@style/BBButtonStyle</item>
    <item name="android:borderlessButtonStyle">@style/BBBorderlessButtonStyle</item>
    <item name="android:colorButtonNormal">#ff0000</item>

  </style>

It's mostly the color of button inside popup dialog that i want to change

zeus
  • 12,173
  • 9
  • 63
  • 184
  • did you check [How to change android button text color globally in theme](https://stackoverflow.com/questions/36261421/how-to-change-android-button-text-color-globally-in-theme)? – Ravi Oct 16 '18 at 10:59
  • I think this previous answer properly fits your needs: https://stackoverflow.com/questions/36261421/how-to-change-android-button-text-color-globally-in-theme/36261451 – Riccardo Coppola Oct 16 '18 at 11:01
  • @RaviRupareliya: I already read this question, but nothing in it work for me :( – zeus Oct 16 '18 at 11:03
  • @RiccardoCoppola I also already read this question, but nothing in it work for me :( – zeus Oct 16 '18 at 11:04
  • @loki can you please elaborate the issue by adding some files like `styles.xml`, `AndroidManifest.xml`, one of the `layout.xml`, etc. This will help us narrow down the issue. – Mohit Ajwani Oct 16 '18 at 11:09
  • @MohitAjwani done, I just updated the question – zeus Oct 16 '18 at 11:10
  • @loki I have submitted a solution. Please check and let me know if it works. – Mohit Ajwani Oct 16 '18 at 11:18
  • @MohitAjwani: no it's didn't help :( – zeus Oct 16 '18 at 11:25

3 Answers3

1

Loki, you can try this. This should change the color of all buttons in your app.

<style name="BBButtonColor" parent="android:Widget.Button">
    <item name="android:textColor">#FF0000</item>
</style>

You were trying to use @android:style/Widget.Button, instead use android:Widget.Button and check. Let me know if this works.

Mohit Ajwani
  • 1,328
  • 12
  • 24
1

You can try this :

<style name="AppTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:buttonStyle">@style/ButtonColor</item>
    <item name="colorButtonNormal">@color/colorname</item>
</style>

<style name="ButtonColor" parent="@android:style/Widget.Button">
    <item name="android:textColor">@color/colorname</item>
</style>

and/change this line in Manifest file :

android:theme="@style/AppTheme.Base
Karishma Patel
  • 469
  • 1
  • 5
  • 16
-1

You should create new style for buttons, something like that:

<style name="optionsButton">
        <item name="android:layout_width">70dp</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:background">@color/white</item>
        <item name="android:textColor">@color/black</item>
        <item name="android:textSize">15sp</item>
    </style>

Now you can set this style for every button you want in layout xml, for example:

                <Button
                android:id="@+id/payCashBtn"
                style="@style/optionsButton"
                android:text="Cash" />

You can see I set layout_width and height in style, so all my buttons which use this style will have same parameters, but you can set different values for every button, or create multiple styles if you used it more than once. I hope it will help you.

Alex P
  • 1
  • 2
  • no, i need to do it globally. I don't use any layout in my app, everything come from material design – zeus Oct 16 '18 at 11:11