Skip to content

Instantly share code, notes, and snippets.

@artzmb
Created August 1, 2017 22:55
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save artzmb/0e50731ad0d521ec1ca3f1e368cb2070 to your computer and use it in GitHub Desktop.
Save artzmb/0e50731ad0d521ec1ca3f1e368cb2070 to your computer and use it in GitHub Desktop.
Android - Selector in vector drawables
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="ru.artzmb.solar.MainActivity">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerInParent="true"
android:clickable="true"
app:srcCompat="@drawable/solar"
tools:ignore="ContentDescription"
/>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/red_800" android:state_selected="true" />
<item android:color="@color/red_800" android:state_pressed="true" />
<item android:color="@color/red" />
</selector>
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="100dp"
android:height="100dp"
android:viewportWidth="100"
android:viewportHeight="100"
android:tint="@color/solar">
<path
android:fillColor="#ffffff"
android:pathData="M35.48 0L50 14.52 64.52 0v32.26L50 46.77 35.48 32.26zM100 35.48L85.48 50 100 64.52H67.74L53.23 50l14.51-14.52zM64.52 100L50 85.48 35.48 100V67.74L50 53.23l14.52 14.51zM0 64.52L14.52 50 0 35.48h32.26L46.77 50 32.26 64.52z"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red">#f44336</color>
<color name="red_800">#c62828</color>
</resources>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment