我有两个xml文件。一个xml文件是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" />
选择器的xml文件包含:
<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" />
我的主要问题是如何将这两个文件用作单个布局元素的背景。
答案 0 :(得分:5)
你不能同时使用它们作为背景,你应该把你的形状xml作为选择器的状态之一(例如你可以把它作为选择器中的默认背景,@drawable/panel_picture_frame_bg_normal
drawable)。