Selector manner using
item_select.xml content, is provided and is pressed without pressing the two colors:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/item_press" android:state_pressed="true"/>
<item android:drawable="@color/item_unpress" android:state_pressed="false"/>
</selector>
Then, not disposed in the GridView item layout file, instead of setting android: listSelector = ""
in the item of the layout file layout or the like, as follows:
<?xml version="1.0" encoding="utf-8"?>
<!--在item布局的布局层,还要设置覆盖子控件的监听事件android:descendantFocusability="blocksDescendants"-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="100dp"
android:layout_height="50dp"
**android:background="@drawable/grid_item_selector"**
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
**android:descendantFocusability="blocksDescendants"**
>
Reference to learn: http://www.cnblogs.com/chenrui7/p/3682613.html