图片定宽,不定高

 Glide.with(context)
                .asBitmap()
                .load(url)
                .into(new SimpleTarget<Bitmap>() {
                    @Override
                    public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
                        imageView.setImageBitmap(resource);
                        float width = SizeUtils.dp2px(106f);
                        float scale = width / resource.getWidth();
                        int afterWidth = (int) (resource.getWidth() * scale);
                        int afterHeight = (int) (resource.getHeight() * scale);
                        ViewGroup.LayoutParams lp = imageView.getLayoutParams();
                        lp.width = afterWidth;
                        lp.height = afterHeight;
                        imageView.setLayoutParams(lp);

                    }
                });

 


版权声明:本文为phenomenon123原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。