Issue
I'm trying to create a drawable painted by color with centered icon. I tried to create layer-list but it scales icon to match drawable size:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="@color/colorImageHolder"/>
</shape>
</item>
<item android:drawable="@drawable/no_photo" android:gravity="center">
</item>
</layer-list>
This is a real device picture:
I want it to look like this:
Is there any way to disable icon scaling ?
UPDATE: My ImageView
has scaleType="centerCrop"
and I think this is a root of problem :( I tried to place no_photo drawable as background but it scales again.
Solution
inside your second <item>
tag add the following <bitmap>
tag so it reads:
<item>
<bitmap android:src="@drawable/no_photo" android:gravity="center" />
</item>
Answered By - pskink
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.