Created
December 6, 2017 23:02
-
-
Save mikovali/9e57c559bc459c932bc984b64f489090 to your computer and use it in GitHub Desktop.
Android activated item background indicator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | |
<item> | |
<selector> | |
<item android:state_activated="true"> | |
<color android:color="?attr/colorControlActivated" /> | |
</item> | |
</selector> | |
</item> | |
<item android:drawable="?attr/selectableItemBackground" /> | |
</layer-list> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Combine
selectableItemBackground
andandroid:activatedBackgroundIndicator
to have touch feedback and activated (selected) indicator.Apply the drawable in your theme:
Then in layout add
android:background="?android:attr/activatedBackgroundIndicator"
.Also works when inflating
android.R.layout.simple_list_item_activated_1
orandroid.R.layout.simple_list_item_activated_2
in adapter.