1

I have two xml files. One xml file is a Shape and the other is a selector. My codes:

The shape:

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

<stroke
    android:width="2dp"
    android:color="#33CCCC" />

<gradient
    android:angle="225"
    android:endColor="#DD33FF66"
    android:startColor="#DD000000" />

<corners
    android:bottomLeftRadius="7dp"
    android:bottomRightRadius="7dp"
    android:topLeftRadius="7dp"
    android:topRightRadius="7dp" />

The xml file for the selector consists of:

    <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:drawable="@drawable/panel_picture_frame_bg_focus_blue" />
<item android:state_pressed="true" android:drawable="@drawable/panel_picture_frame_bg_pressed_blue" />
<item android:drawable="@drawable/panel_picture_frame_bg_normal" />

My main problem is how can I use these two files as a background for a single layout element.

user
  • 86,916
  • 18
  • 197
  • 190
Prativa
  • 364
  • 6
  • 25

1 Answers1

5

You can't use both as background, you should put your shape xml as one of the states of the selector(for example you could put it as the default background in the selector, the @drawable/panel_picture_frame_bg_normal drawable).

user
  • 86,916
  • 18
  • 197
  • 190
  • look this [android-how-apply-shape-and-selector-simultaneously-for-button](https://stackoverflow.com/questions/7606995/android-how-apply-shape-and-selector-simultaneously-for-button) – xiaoyee Aug 25 '15 at 03:46