Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 455
Katedral Pillon Avatar asked Feb 16 '16 15:02

Katedral Pillon


2 Answers

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" />
like image 182
Bryan Herbst Avatar answered Nov 01 '22 15:11

Bryan Herbst


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>
like image 40
Sokol Sokolinskiy Avatar answered Nov 01 '22 17:11

Sokol Sokolinskiy