James
James

Reputation: 14091

Applying background image to a shape

I dont know whether I am asking is wrong or not. But can I have an image in this shape xml so that if provide an image then it's corners become rounded.

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android">  
    <corners android:radius="5dp" /> 
    <solid android:color="#F87217"/> 
    <stroke
        android:width="1dip"
        android:color="#f0f0f0" />
</shape> 

Upvotes: 4

Views: 4199

Answers (1)

You may try this

<item
    android:drawable="@drawable/ic_broadcast"
    android:left="3px"
    android:right="3px"
    android:top="3px">
    <shape android:shape="rectangle" >
        <solid android:color="#cc2b2b" />


        <corners android:radius="8dp" />
    </shape>

</item>

ic_broadcast is an image from your res folder

Upvotes: 1

Related Questions