我想创建以下设计,因此我创建了动态图像视图并使用Glide lib获取图像网址。但加载图像非常慢
holder.linearLayout.removeAllViews();
for(int k = 0; k < getPicList().size(); k++) {
ImageView imageView = new ImageView(holder.linearLayout.getContext());
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(90, 90);
params.setMargins(0,0,10,0);
imageView.setLayoutParams(params);
getpic(holder.linearLayout, imageView, requestData.getPicList().get(k).getPic());
}
private void getpic(final LinearLayout linearLayout, final ImageView imageView, String imageUrl){
// Log.d(TAG,imageUrl);
if (imageUrl != null) {
// Loading profile image
Glide.with(context).load(imageUrl)
// .crossFade()
.dontAnimate()
.priority(Priority.IMMEDIATE)
.signature(new StringSignature(String.valueOf(System.currentTimeMillis())))
// .placeholder()
.error(R.drawable.ic_error_image_load)
.thumbnail(0.5f)//size multiplier must be 0 and 1
.bitmapTransform(new CircleTransform(context))
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(new SimpleTarget<GlideDrawable>() {
@Override
public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
imageView.setImageDrawable(resource);
linearLayout.addView(imageView);
}
});
} else {
// make sure Glide doesn't load anything into this view until told otherwise
Glide.clear(employee_img);
// remove the placeholder (optional); read comments below
employee_img.setImageDrawable(null);
}
}
这是为这种UI选择动态图像视图的正确方法,还是有其他选择?