H1,我有RecyclerView适配器,它通过url动态创建ImageView并加载图片:
ImageView image;
if (list.size() > 0) {
if (list.size() > 2) {
holder.attachments.setVisibility(View.VISIBLE);
holder.attachments_multi.setVisibility(View.VISIBLE);
} else {
holder.attachments.setVisibility(View.VISIBLE);
holder.attachments_multi.setVisibility(View.GONE);
}
for (int i = 0; i < list.size(); i ++) {
image = createImage();
imageLoader.cancelDisplayTask(image);
if (i < 2) {
holder.attachments.addView(image);
} else {
holder.attachments_multi.addView(image);
}
loadImage(imageLoader, image, apiSettings.server_images + list.get(i), options);
}
} else {
holder.attachments.setVisibility(View.GONE);
holder.attachments_multi.setVisibility(View.GONE);
}
创建简单的图像:
ImageView image = new ImageView(mContext);
...
return image
holder.attachments - 前2张图片的LinearLayout
holder.attachments_multi - 其他图片的LinearLayout;
物品ImageView滚动时位置错误。什么问题?