需要在GridView的每个item上显示一个编辑层,编辑层上有四个按钮,起初是用ImageView来做的这四个按钮,但发现一个百思不得骑姐的问题。
使用ImageView做为按钮的效果图:
当在编辑层上点中间的空白处时,四个按钮的状态背景图竟然同时触发了,这是不希望出现的情况。
希望达到的效果是只有点击了相应的按钮才会触发相应的状态背景,点空白的地方是不希望触发任何状态背景图的。
布局如下:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/rl_zbEditStatus"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="56dip"
android:background="@drawable/book_edit_bg"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/selector_zbedit_set"
android:id="@+id/zb_edit_set"
android:layout_marginLeft="15dip"
android:layout_marginTop="15dip"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/selector_zbedit_del"
android:id="@+id/zb_edit_del"
android:layout_below="@id/zb_edit_set"
android:layout_marginLeft="15dip"
android:layout_marginTop="30dip"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/selector_zbedit_desktop"
android:layout_alignParentRight="true"
android:layout_marginRight="15dip"
android:layout_marginTop="15dip"
android:id="@+id/zb_edit_desktop"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/selector_zbedit_upgrade"
android:layout_alignParentRight="true"
android:layout_below="@id/zb_edit_desktop"
android:layout_marginRight="15dip"
android:layout_marginTop="30dip"
android:id="@+id/zb_edit_upgrade"
/>
</RelativeLayout>
在网上完全查不到这样类似的问题。
起初以为是布局的问题,把RelativeLayout改成了LinearLayout,把wrap_content改成fill_parent问题依然存在,这个布局中除了RelativeLayou就只能是ImageView了,最后把ImageView改成了Button达到了希望的效果。
然后我又在网上搜索了ImageView和Button的状态背景图问题,也没有类似这样的问题。
此问题只能暂时以Button替换ImageView来解决了。