1

I have a shape (rectangle) for ListItem selector:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"   android:shape="rectangle" >
<solid android:color="#eef0f3" />
<corners
    android:bottomLeftRadius="4dp"
    android:bottomRightRadius="4dp"
    android:topLeftRadius="4dp"
    android:topRightRadius="4dp" />
</shape>

It's rectangle with color #eef0f3, but I need use background image instead of:

<solid android:color="#eef0f3" />

How can I to do this?

Andrew Efremov
  • 423
  • 5
  • 12
  • may this help you http://stackoverflow.com/questions/21002224/add-a-background-image-to-shape-in-xml-android – Pavan Sep 25 '15 at 09:18

1 Answers1

3

You could use a layer-list instead of a shape.

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:drawable="@drawable/button_image" />
    <item>
        <shape android:shape="rectangle">
            <corners
                 android:bottomRightRadius="4dp"
                 android:bottomLeftRadius="4dp"
                 android:topLeftRadius="4dp"
                 android:topRightRadius="4dp"/>
         </shape>
   </item>

You will also need to add rounded corners to the image. To do this, look up:

How to make an ImageView with rounded corners?

Community
  • 1
  • 1
Rachit
  • 3,173
  • 3
  • 28
  • 45