The following is the custom ripple style of button:
Button
<Button
android:id="@+id/stop"
style="@style/btn_start_style"
android:layout_width="fill_parent"
android:layout_height="48dp"
android:layout_margin="5dp"
android:layout_weight="1"
android:text="@string/start"
android:textSize="18dp"
android:textStyle="bold" >
</Button>
Style: btn_start_style
If I set "Background" in XML,the "style" will not working,so I set "Background" in "style".
<style name="btn_start_style" parent="android:style/Widget.Material.Button">
<item name="android:background">@drawable/btn_raised_start</item>
<item name="android:textColor">@color/white</item>
</style>
Background: btn_raised_start.xml
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?attr/colorControlHighlight">
<item>
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<solid android:color="@color/btn_start"/>
</shape>
</item>
When click a "Raised Button",I want to change the BackgroundColor.
btnStop.setBackgroundColor(getResources().getColor(R.color.btn_start_day));
But when I change the BackgroundColor by the above code,the ripple gone!