9

i have a xml as below i trying to add a image from drawable folder but its not working.

<solid android:color="#FFF"/> this is where i need to add image from drawable folder

<shape xmlns:android="http://schemas.android.com/apk/res/android">
        <solid android:color="#FFF"/>
        <stroke android:width="1dip" android:color="#225786" />
        <corners android:radius="10dip"/>
        <padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
    </shape>

is there any other way that i can add i tried with layer list with item this is how i have tried

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">  
    <item android:drawable="@drawable/background">
        <shape>
            <solid/>
            <stroke android:width="1dip" android:color="#225786" />
            <corners android:radius="10dip"/>
            <padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
        </shape>
    </item> 
  </layer-list> 

Now its not displaying the border which i am doing with shape it only adds a background to it.

Goofy
  • 6,098
  • 17
  • 90
  • 156

1 Answers1

14

If your want a background with border, try this:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">  
    <item android:drawable="@drawable/background" />
    <item 
        <shape>
            <solid/>
            <stroke android:width="1dip" android:color="#225786" />
            <corners android:radius="10dip"/>
            <padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
        </shape>
    </item> 
  </layer-list> 

and if your just want a background, try this one:

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/background"
    android:tileMode="repeat" >

</bitmap>
Sadegh
  • 2,669
  • 1
  • 23
  • 26
  • ok thanks it works but only a small issue the image which i am setting as a background is square and the shape which i am adding is of rounded corners so the background image sharp edges are showing so can we add some stroke to that? – Goofy Jan 17 '13 at 10:59
  • I don't know how, but maybe you should just play with background image – Sadegh Jan 17 '13 at 11:09
  • Am not getting corner radius effect? – vignesh May 02 '13 at 17:32