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.
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_normaldrawable).