1. 程式人生 > >android glide載入原圖顯示

android glide載入原圖顯示

final ViewGroup.LayoutParams lp = topicContentHolder.img.getLayoutParams();Glide.with(context)
        .load(subBeanList.get(position).imgUrl).asBitmap()
        .into(new SimpleTarget<Bitmap>() {
            @Override
public void onResourceReady(Bitmap bitmap,
                                        GlideAnimation<? super 
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); } });