Android xml add shadow using a drawable behind solid color shape -
Android xml add shadow using a drawable behind solid color shape -
i have .png image circular shape , shadow. have imagebutton
has image it's android:src
property. it's background can have xml file in drawable file. want have shadow image png go behind solid shape -> android:shape="oval".
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/shadowimg" /> <item> <shape android:shape="oval"> <solid android:color="#d63a33"/> <size android:width="70dp" android:height="70dp"/> </shape> </item> </layer-list>
as see in code adding item shadow image android:drawable
property. not allow shadow show. shows reddish circle shape. want shadow image behind solid reddish circle shape. tiny knowledge of layer-list top item goes in , 1 on bottom comes first.
update: after moving image shadow bottom got effect size of solid reddish circle shape big , changing size doesn't alter size.
updated code:
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="oval"> <solid android:color="#d63a33"/> <size android:width="5dp" android:height="5dp"/> </shape> </item> <item android:drawable="@drawable/shadowimg" /> </layer-list>
**** update 2: **** noticed when remove <item android:drawable="@drawable/shadowimg" />
can alter size of solid circle shape when add together defaults bigger size.
this happens:
here's shadow image if needs:
i think should solution:
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:shape="oval" > <solid android:color="#d63a33" /> <size android:height="5dp" android:width="5dp" /> </shape> </item> <item> <bitmap android:src="@drawable/shadowimg" /> </item> <item> <shape android:shape="oval" > <solid android:color="#00000000" /> <size android:height="5dp" android:width="5dp" /> </shape> </item> </layer-list>
i added transparent layer desired size.
android xml drawable layer-list
Comments
Post a Comment