kashyap
kashyap

Reputation: 81

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.

Upvotes: 5

Views: 17477

Answers (1)

Fran&#231;ois Legrand
Fran&#231;ois Legrand

Reputation: 1233

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 android:drawable="@drawable/your_drawable"/>
</layer-list>

Upvotes: 23

Related Questions