您当前的位置: 首页 >  ide

梁同学与Android

暂无认证

  • 3浏览

    0关注

    618博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Android --- Glide加载图片时候调用asBitmap()方法的时候总是报错,点不出来?

梁同学与Android 发布时间:2021-11-07 16:01:11 ,浏览量:3

今天写Glide加载图片的时候,网上给的例子全都是这样写的 在这里插入图片描述很明显.asBitmap()在load后面,放到我的代码里就会报错,如下: 在这里插入图片描述 最后查了半天度娘才发现要在with()之后添加asBitmap(),而不是load 真的坑啊。正确代码如下:

  ImageView imageView = baseViewHolder.getView(R.id.iv_image_id);
    Glide.with(context).asBitmap().load(QiNiuRef.domain + "/" + images[0]).into(new SimpleTarget() {
        @Override
        public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition transition) {
            int imageWidth = resource.getWidth();
            int imageHeight = resource.getHeight();
            int height = ScreenUtils.getScreenWidth() * imageHeight / imageWidth;
            ViewGroup.LayoutParams para = imageView.getLayoutParams();
            para.height = height;
            para.width = ScreenUtils.getScreenWidth();//屏幕的宽度,没有工具类自己从网上搜
            imageView.setImageBitmap(resource);
        }
    });
关注
打赏
1660730345
查看更多评论
立即登录/注册

微信扫码登录

0.0477s