Reputation: 807
I want to use Lollipop Button with custom background color like the buttons (Force stop and uninstall) in following picture. When I use
<Button
android:background="#F44336"
.... />
the ripple effect, shadow and elevation are gone. And I cannot use two different colors by adding style. Is there anyway to achieve it?
Upvotes: 2
Views: 1103
Reputation: 4640
You can use a drawable to create a ripple effect and set a background color.
<ripple
xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:colorControlHighlight">
<!-- Note: <ripple> acts like a layer-list -->
<item android:id="@android:id/mask">
<shape android:shape="oval">
<!-- This color is not displayed in any way -->
<solid android:color="@android:color/black" />
</shape>
</item>
<!-- This is the border -->
<item>
<shape android:shape="rectangle">
<solid android:color="#f0600000"/>
<stroke android:width="1dp" android:color="#f00"/>
</shape>
</item>
</ripple>
Put in in drawable
folder and set it as your button's background.
Upvotes: 2