vxh.viet
2/22/2018 - 7:09 AM

Change background of Material Button

#How to change background of Material Button

Android Design Patterns, Medium, Medium

The first one works. The other two don't but stiff leave there for reference purposes.

Create this theme in res/values/styles.xml

<style name="RewardRedeemButtonTheme" parent="ThemeOverlay.AppCompat.Light">
        <item name="colorAccent">@color/white_tint_1</item>
</style>

Apply it to the button like this

    <android.support.v7.widget.AppCompatButton
        android:id="@+id/item_reward_redeem_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/text_redeem"
        android:textAppearance="@style/TextAppearance.AppCompat.Button"
        android:textColor="@color/black_tint_3"
        android:textSize="12sp"
        style="@style/Widget.AppCompat.Button.Colored" //need this for press effect
        android:theme="@style/RewardRedeemButtonTheme" //this will change the background
/>