Katedral Pillon
Katedral Pillon

Reputation: 14864

How to make custom ripple borderless

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?

Upvotes: 5

Views: 3361

Answers (2)

Sokol Sokolinskiy
Sokol Sokolinskiy

Reputation: 11

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>

Upvotes: 1

Bryan Herbst
Bryan Herbst

Reputation: 67249

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" />

Upvotes: 6

Related Questions