我的gridView 显示本地存储的图片(imageItem),使用Picasso展示。当通过点击右上角的选中图标选择图片时,图片的状态会更改,并在选定状态下带有蓝色边框,如下所示:
我尝试了以下代码:
public void onClick(View v) {
if(!v.isSelected()){
imageItem.setBackgroundResource(R.drawable.photoborder);
}else{
imageItem.setBackgroundDrawable(null);
}
}
});
在图片未加载时,我能看到边框。当Picasso完成图片的加载后,边框被覆盖了:
如何在ImageView上设置图片边框?非常感谢任何建议!!
以下是每个图片项的布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<custome.SquaredImageView
android:id="@+id/image_item_in_gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/ic_launcher"
android:background="@drawable/attachment_gallery_images_items_background" />
<ImageView
android:id="@+id/imageCheckStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="2dp"
android:layout_marginTop="2dp"
android:padding="2dp"
android:src="@drawable/abc_ic_cab_done_holo_dark" />
</RelativeLayout>
ImageView
作为背景层,勾选标记指示器作为前置层。你所做的是设置ImageView
的背景,而不是前置层。如果您能够发布适配器中使用的 XML 布局,可能会更清晰明了。 - Andrew T.