Skip to content

Instantly share code, notes, and snippets.

@StKotok
Last active August 5, 2017 20:05
Show Gist options
  • Save StKotok/d050faa1c3ab57e9ec6bca66c38d7e36 to your computer and use it in GitHub Desktop.
Save StKotok/d050faa1c3ab57e9ec6bca66c38d7e36 to your computer and use it in GitHub Desktop.
selector for ListView with custom highlight effect API<21
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Selected -->
<item android:state_focused="true" android:state_pressed="false">
<shape>
<solid android:color="#00ffffff" />
</shape>
</item>
<!-- Pressed -->
<item android:state_pressed="true">
<shape>
<solid android:color="#0b000000" />
<corners android:radius="6dp" />
</shape>
</item>
</selector>
------------- layout.xml ---------------
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawSelectorOnTop="true"
android:listSelector="@drawable/list_selector" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment