kashyap kashyap - 1 month ago 5
Android Question

How to add a image to drawable xml in android

I have a drawable xml file which draws a circle.

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">

<solid

android:color="#666666" />

<size
android:width="120dp"
android:height="120dp" />
</shape>


now, I have to add a image in drawable folder. please help me where to change the code.

Answer

You can use a layer list like this

<?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="#666666"/>

           <size
               android:width="120dp"
               android:height="120dp"/>
       </shape>
   </item>

   <item>
       <bitmap android:src="@drawable/your_drawable"/>
   </item>
</layer-list>
Comments