Reputation: 5
I'm trying to achieve that whenever the users touches the icon it changes color to a darker one, I have done it perfectly using PNGs but for some reason it's not working anymore since I used SVGs files:
filter_icon.xml:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/filter_icon_pressed" />
<item android:state_focused="true" android:drawable="@drawable/filter_icon_pressed" />
<item android:drawable="@drawable/filter_icon_static" />
</selector>
filter_icon_static.xml:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="130dp"
android:height="130dp"
android:viewportWidth="130"
android:viewportHeight="130">
<path
android:pathData="M125,9L5,9a5,5 0,0 0,0 10L125,19a5,5 0,0 0,0 -10Z"
android:fillColor="#13293d"/>
<path
android:pathData="M125,42.84L5,42.84a5,5 0,0 0,0 10L125,52.84a5,5 0,0 0,0 -10Z"
android:fillColor="#13293d"/>
<path
android:pathData="M125,76.9L5,76.9a5,5 0,0 0,0 10L125,86.9a5,5 0,0 0,0 -10Z"
android:fillColor="#13293d"/>
<path
android:pathData="M125,111L5,111a5,5 0,0 0,0 10L125,121a5,5 0,0 0,0 -10Z"
android:fillColor="#13293d"/>
<path
android:pathData="M5,14.03a14,14.03 0,1 0,28 0a14,14.03 0,1 0,-28 0z"
android:fillColor="#13293d"/>
<path
android:pathData="M102,47.85a14,14.03 0,1 0,28 0a14,14.03 0,1 0,-28 0z"
android:fillColor="#13293d"/>
<path
android:pathData="M51,81.91a14,14.03 0,1 0,28 0a14,14.03 0,1 0,-28 0z"
android:fillColor="#13293d"/>
<path
android:pathData="M85,115.97a14,14.03 0,1 0,28 0a14,14.03 0,1 0,-28 0z"
android:fillColor="#13293d"/>
</vector>
What should I make to let the color of the filter icon change once the user touches it?
Upvotes: 0
Views: 25
Reputation: 208
Ref : http://developer.android.com/training/material/animations.html,
http://wiki.workassis.com/category/android/android-xml/
<ImageView
.
.
.
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
Upvotes: 1