I\'m creating application using com.android.support:appcompat-v7:23.0.1
library.
I define application theme in values/styles.xml
:
After some research and googling I defined separate themes for different raised and flat buttons:
<style name="AppTheme.RaisedButton">
<item name="buttonStyle">@style/Widget.AppCompat.Button.Colored</item>
</style>
<style name="AppTheme.RaisedButton.Primary">
<item name="colorAccent">@color/primary</item>
</style>
<style name="AppTheme.RaisedButton.Accent">
</style>
<style name="AppTheme.FlatButton">
<item name="buttonStyle">@style/Widget.AppCompat.Button.Borderless.Colored</item>
<item name="colorControlHighlight">@color/highlight_light</item>
</style>
<style name="AppTheme.FlatButton.Primary">
<item name="colorAccent">@color/primary</item>
</style>
<style name="AppTheme.FlatButton.Accent">
</style>
Note, that I'm using buttonStyle
attribute not android:buttonStyle
because it will not work on pre-lollipop devices.
Use these themes in android:theme
attribute:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/my_button"
android:theme="@style/AppTheme.FlatButton.Primary" />