Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android layer-list : bitmap issue with app:srcCompat

After updating to Studio 2.3 when i tried to create a layer list with a vector drawable it prompt to use app:srcCompat instead of android:src in bitmap.

can any one help me to add vector drawable to layer list ?

<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android">  <item android:drawable="@color/colorWhite" />  <item>     <bitmap         android:gravity="center"         app:srcCompat="@drawable/login">     </bitmap>  </item>  </layer-list> 

Already added

vectorDrawables.useSupportLibrary = true 
like image 899
Boban Avatar asked Mar 09 '17 09:03

Boban


2 Answers

I found a solution for your problem

Modify second item to this:

<item android:gravity="center" android:drawable="@drawable/login"/> 

UPDATE

this will cause crash on API < 21. There is not any better way.

like image 133
DrMorteza Avatar answered Oct 09 '22 05:10

DrMorteza


I managed to do it the following way:

<item     android:gravity="center"     android:drawable="@drawable/login" /> 
like image 40
SapuSeven Avatar answered Oct 09 '22 04:10

SapuSeven