我为 ListFragment 使用选择器
我的 ListFragment 的 xml
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F1F4F2"
android:orientation="horizontal" >
<fragment
android:name="usanin.max.gps_logger.Fragment_Left"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5" />
<FrameLayout
android:id="@+id/frag_content"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="2" />
</LinearLayout>
项目 ListFragment 的 xml
<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
<item android:state_focused="true" 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>
<item android:state_focused="false" android:state_pressed="true"><shape>
<gradient android:angle="90.0" android:color="#F1F4F2" android:endColor="#53AC71" android:startColor="#53AC71" android:type="linear" />
<corners android:radius="5.0dp" />
</shape></item>
<item android:state_activated="true"><shape>
<gradient android:angle="90.0" android:endColor="#3DF5E9" android:startColor="#3DF5E9" android:type="linear" />
<corners android:radius="5.0dp" />
</shape></item>
<item><shape>
<gradient android:angle="90.0" android:endColor="#8E9C8B" android:startColor="#8E9C8B" android:type="linear" />
<corners android:radius="5.0dp" />
</shape></item>
但是我有一个问题,当我按下按钮时 - 颜色背景改变了
我试图在按下“android:background”时设置选择器但不起作用