android glide加载原图显示

final ViewGroup.LayoutParams lp = topicContentHolder.img.getLayoutParams();
Glide.with(context)
        .load(subBeanList.get(position).imgUrl).asBitmap()
        .into(new SimpleTarget() {
            @Override
            public void onResourceReady(Bitmap bitmap,
                                        GlideAnimationsuper Bitmap> glideAnimation) {
                int width = bitmap.getWidth();
                int height = bitmap.getHeight();
                //40点参数是因为viewHolder里面有距左距右各20DP的原因
                lp.width= ScreenUtil.getScreenWidth(context)-(int)ScreenUtil.dpToPxInt(context,40);
                float tempHeight = height * ((float) lp.width / width);
                lp.height = (int) tempHeight;
                topicContentHolder.img.setLayoutParams(lp);
                topicContentHolder.img.setImageBitmap(bitmap);
            }
        });

你可能感兴趣的:(andorid)