Stylizing buttons in Android
Buttons are very simple elements in Android which can perform certain actions on click. These actions can be defined by implementing an onClick Listener.
The default buttons provided by Android have a grey color with ripple effect but many-a-time, this button does not go with your theme. You can set a background color to the Button
, but then you will not get any effect on click. This can be solved by simply using the material theme for the button. You can do this by either adding the following style:
style="@style/Widget.AppCompat.Button.Colored"
or by selecting it from the style dropdown in the properties panel of the Button
On applying this style, you will get the following result:
You will see that the onClick effect is intact. The style takes the color of the colorAccent declared in your theme in the styles.xml.