我将其选择用于列表
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/arrow"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|left"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical" >
<TextView
android:id="@+id/tvDescr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" >
</TextView>
</LinearLayout>
<ImageView
android:id="@+id/ivImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:maxHeight="20dp"
android:minHeight="20dp" >
</ImageView>
</LinearLayout>
和选择器 arrow.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item><shape>
<gradient android:angle="90.0" android:endColor="#6495ED" android:startColor="#0000FF" android:type="linear" />
<corners android:radius="5.0dp" />
</shape></item>
<item android:state_focused="true"><shape>
<gradient android:angle="90.0" android:endColor="#BA55D3" android:startColor="#800080" android:type="linear" />
<corners android:radius="5.0dp" />
</shape></item>
<item android:state_pressed="true"><shape>
<gradient android:angle="90.0" android:endColor="#BA55D3" android:startColor="#800080" android:type="linear" />
<corners android:radius="5.0dp" />
</shape></item>
</selector>
结果是
- 不起作用,但如果我删除(以下来源)它将起作用
<item><shape>
<gradient android:angle="90.0" android:endColor="#6495ED" android:startColor="#0000FF" android:type="linear" />
<corners android:radius="5.0dp" />
</shape></item>
但这并没有给我想要的结果,因为在您单击“列表按钮”后样式必须更改-但这不会发生
我要实现:
1)按下前的样式如图1
2)按下按钮后,按钮样式必须更改为2图片
3)保持这种状态,直到我点击另一个按钮