I am attempting to use a VectorDrawable
in a LayerList
without scaling the vector. For example:
<layer-list>
<item android:drawable="@color/grid_item_activated"/>
<item android:gravity="center" android:drawable="@drawable/ic_check_white_48dp"/>
</layer-list>
The drawable ic_check_white_48dp
id defined as:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"/>
</vector>
The desired effect is for the check icon to be centered in the layer drawable, without scaling. The issue is, the layer-list above causes the check icon to be scaled to fit the layer size.
I can produce the desired effect if I replace the vector drawable with PNGs for each density and modify the layer-list as such:
<layer-list>
<item android:drawable="@color/grid_item_activated"/>
<item>
<bitmap android:gravity="center" android:src="@drawable/ic_check_white_48dp"/>
</item>
</layer-list>
Is there any way I can do this using a VectorDrawable
?