How to make custom ripple borderless
Asked Answered
T

2

5

Here is my custom ripple

<ripple xmlns:android="http://schemas.android.com/apk/res/android"
        android:color="?android:colorControlHighlight">
        <item android:drawable="@color/white" />
</ripple>

How do I make it borderless?

Tempa answered 16/2, 2016 at 15:42 Comment(2)
What do you mean by borderless? Are you talking about a button?Endoplasm
Here is an example of a borderless ripple: android:background="?attr/selectableItemBackgroundBorderless"Tempa
E
6

As per the RippleDrawable documentation, a ripple will be masked against the composite of its child layers.

In this case, your drawable will be masked by the only item in your ripple.

To have a ripple with no mask, you can define your ripple like so:

<ripple android:color="?android:colorControlHighlight" />
Elegant answered 16/2, 2016 at 15:49 Comment(0)
P
1

I had the same problem, while I stumbled upon this question. I have solved my problem easily and there is a code

Btw it works only for cases when height equals width. Else it will be not ?attr/selectableItemBackgroundBorderless, but ripple oval

<?xml version="1.0" encoding="utf-8"?>
<ripple android:color="@color/grayPrimary" xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@android:id/mask">
        <shape android:shape="oval">
            <solid android:color="#000000"/>
        </shape>
    </item>
</ripple>
Pia answered 20/4, 2020 at 11:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.