On the dialer app of Android, when you start searching for something, and you click the arrow button on the left of the EditText, you get a circular ripple
Try:
android:background="@android:color/transparent"
android:clickable="true"
android:focusable="true"
android:foreground="?actionBarItemBackground"
If you are using AppCompat theme, then you could set the background of the view as:
android:background="?selectableItemBackgroundBorderless"
This will add circular ripple on 21 and above and square background on below 21.
android:background=?android:attr/actionBarItemBackground
If you already have a background image, here is an example of a ripple that looks close to selectableItemBackgroundBorderless:
<ImageButton
android:id="@+id/btn_show_filter_dialog"
android:layout_width="24dp"
android:layout_height="24dp"
android:background="@drawable/ic_filter_state"/>
ic_filter_state.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:state_enabled="true"
android:drawable="@drawable/state_pressed_ripple"/>
<item
android:state_enabled="true"
android:drawable="@drawable/ic_filter" />
</selector>
state_pressed_ripple.xml: (opacity set to 10% on white background) 1AFFFFFF
<?xml version="1.0" encoding="UTF-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="oval">
<solid android:color="#1AFFFFFF"/>
</shape>
<color android:color="#FFF"/>
</item>
</ripple>
If you want more generic XML files, I have two files:
1) btn_ripple_background with code:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:state_enabled="true"
android:drawable="@drawable/ripple_circular_shape"/>
</selector>
2) ripple_circuler_shape with code:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/btn_state_pressed_text_color"
android:shape="oval">
<solid android:color="@color/btn_state_pressed_text_color" />
</shape>
finally the usage:android:foreground="@drawable/ripple_btn_background"
You can create circle ripple drawable using android:radius
attribute in xml.
Example:
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="your_color"
android:radius="your_radius" />
Pay attention, that your your_radius
should be less then your view width and height.
For example: if you have view with size 60dp x 60dp
your_radius
should be near 30dp
(width / 2 or height / 2).
Work on Android 5.0 and above.