Issue
I am trying to create a compound background adding shape drawable and search icon from Android Studio's vector asset. But instead of the search icon, it draws something indicating an error.
Here is my drawable file:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="44dp" android:height="24dp" android:gravity="center">
<shape android:shape="rectangle">
<corners android:radius="@dimen/parcel_indicator_corner_radius"/>
<solid android:color="@color/colorAccent"/>
</shape>
</item>
<item android:gravity="center" android:width="24dp" android:height="24dp">
<bitmap android:src="@drawable/ic_search_white_24dp" />
</item>
</layer-list>
Does anybody have ideas why search icon might not be visible?
Solution
The issue is here
set the android:drawable property for an item instead of setting up the Bitmap
<item android:gravity="center" android:width="24dp" android:height="24dp">
<bitmap android:src="@drawable/ic_search_white_24dp" />
</item>
Replace with
<item
android:width="24dp"
android:height="24dp"
android:drawable="@drawable/ic_search_white_24dp"
android:gravity="center">
</item>
Answered By - Jaymin

0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.