0

so im trying to add all the buttons the next style:

    style="@style/Widget.AppCompat.Button.Borderless"

But I dont know how to do it from the styles.xml and I dont want to add each button that style I just wanted it to be the default on that apps I also would like to change the background color of the all the buttons

How do I do it?

NivSaparov
  • 47
  • 2
  • 7
  • something like this https://stackoverflow.com/a/28963960/3276822 So add this android:background="?android:attr/selectableItemBackground" to the style instead of using borderless style – Sagar Jun 20 '18 at 21:07
  • I am using API15, so i cant use parent="@android:style/Theme.Material.NoActionBar" if i delete it and just use : its just giving me those attribute in my buttons, but I dont want it.. I just want my button to be boardless and change his background.. I wanted to keep to default attribute and not overide them all – NivSaparov Jun 20 '18 at 21:09
  • Your style "MyButton" will override everything if it doesn't have a parent class. Can you look at this ? There are plenty of questions on this, perhaps if this doesn't work. I'll try on Android studio. Let me know https://stackoverflow.com/questions/2410836/how-do-i-apply-a-style-to-all-buttons-of-an-android-application – Sagar Jun 20 '18 at 21:15

1 Answers1

0

Create a custom style for your button, inheriting from @style/Widget.AppCompat.Button.Borderless and then use it on a custom theme:

<style name="CustomTheme" parent="ThemeAppCompat">
  <item name="android:buttonStyle">@style/CustomButton</item>
  <item name="buttonStyle">@style/CustomButton</item>
</style>

<style name="CustomButton" parent="@style/Widget.AppCompat.Button.Borderless">
</style>
Eduardo Naveda
  • 1,880
  • 3
  • 15
  • 30