【发布时间】:2014-09-03 22:24:07
【问题描述】:
我的 gridView 使用 Picasso 显示来自本地存储的图像 (imageItem)。通过单击右上角的选择图标选择图像时,图像的状态会发生变化,并且在选定状态下,图像具有如下蓝色边框:
我试过这样的:
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>
【问题讨论】:
-
我不太确定,因为我不使用毕加索,但似乎使用了不止 1 层:
ImageView作为后层,复选标记指示器作为前层。您正在做的是设置ImageView的背景,而不是前层。如果您可以发布适配器中使用的 XML 布局,也许会更清楚。
标签: android gridview imageview