像这样试试
它可以通过Selector来实现。
在 grid_cell_item 的根布局上使用选择器作为背景。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/artists_list_backgroundcolor"
android:orientation="vertical" >
<ImageView
android:id="@+id/home_grid_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:contentDescription="@string/app_name" />
<TextView
android:id="@+id/home_grid_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/home_grid_img"
android:layout_centerHorizontal="true"
android:textColor="#7a7a7a"
android:textSize="12sp"
android:textStyle="bold" />
</RelativeLayout>
艺术家列表背景色.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_selected="false"
android:state_pressed="false"
android:drawable="@color/white" />
<item android:state_pressed="true"
android:drawable="@color/itemselected" />
<item android:state_selected="true"
android:state_pressed="false"
android:drawable="@color/itemselected" />
</selector>
颜色.xml
<resources>
<color name="white">#ffffff</color>
<color name="itemselected">#EDEDED</color>
</resources>
希望这会帮助你。