Extends:http://stackoverflow.com/questions/26346727/android-material-design-button-styles
I'll add my answer since I don ' t use any of the other answers provided.
With the-support Library V7, all the styles is actually already defined and ready-to-use, for the standard buttons, all O F These styles are available: style="@style/Widget.AppCompat.Button"style="@style/Widget.AppCompat.Button.Colored"style="@style/Widget.AppCompat.Button.Borderless"style="@style/Widget.AppCompat.Button.Borderless.Colored"
Widget.AppCompat.Button:
Widget.AppCompat.Button.Colored:
Widget.AppCompat.Button.Borderless
Widget.AppCompat.Button.Borderless.Colored:
|
How to change the color
For the whole app:
The color of the UI controls (not only buttons, but also floating action buttons, checkboxes etc) are managed by the A Ttribute as colorAccent explained here. Can modify this style and apply your own color in your theme definition:
<name= "Apptheme" parent= "Theme.AppCompat.Light.NoActionBar" > ... < name= "coloraccent">@color/orange</Item > </ style >
For a specific button:
If you need to change the style of a specific button, you can define a new style, inheriting one of the parent St Yles described above. In the example below I just changed the background and font colors:
<style name= "Apptheme.button" parent= "Widget.AppCompat.Button.Colored" > <item name= " Colorbuttonnormal "> @color/red</item> <item name=" Android:textcolor "> @color/white</item ></style>
Then you just need to apply this new style on the button with:
Android:theme= "@style/apptheme.button"
To set a default button design in a layout, add the Styles.xml theme:
<item name= "ButtonStyle" > @style/btn</item>
Where is @style/btn your button theme. This sets the button style is all of the buttons in a layout with a specific theme
Android Change button style buttons styles