Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Drawable for a touch hover effect pre lollipop and with ripple effect and an example usage
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:exitFadeDuration="@android:integer/config_shortAnimTime">
<item android:state_pressed="false">
<color android:color="@android:color/transparent"/>
</item>
<item android:state_pressed="true">
<!--<color name="touch_hover">#44565656</color> -->
<color android:color="@color/touch_hover" />
</item>
<item android:drawable="@android:color/transparent" />
</selector>
<!-- res/drawables-v21 -->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/touch_hover">
<!--<color name="touch_hover">#44565656</color> -->
<item
android:id="@android:id/mask"
android:drawable="@android:color/white" />
</ripple>
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:padding="8dp"
android:layout_margin="8dp"
android:layout_height="200dp">
<ImageView
android:layout_height="match_parent"
android:src="@drawable/example"
android:layout_width="match_parent"/>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/touch_effect"/>
</android.support.v7.widget.CardView>
</layout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment