Resize images with Glide in a ImageView Android

前端 未结 6 1222
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-14 16:24

I have a lot of doubts about the treatment of the images in android, and I was hoping to see if you could solve them.

At this point I have an image that occupies 320

6条回答
  •  暖寄归人
    2020-12-14 16:46

    Glide 4.x - If you want get bitmap, try:

    Glide.with(mContext).asBitmap().
                            load(pictureUri)
                            .apply(new RequestOptions().override(50, 50))
                            .listener(new RequestListener() {
                                @Override
                                public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
                                    return false;
                                }
                            @Override
                            public boolean onResourceReady(Bitmap resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) {
                                // resource is your loaded Bitmap
                                imgView.setImageBitmap(resource);
                                return true;
                            }
                        }).submit();
    

提交回复
热议问题