recycleview实现九宫格图片加载不全的问题

测试中发现:某平板只能显示5个item,各种找原因,最后是因为fresco加载图片不会根据view的大小而进行处理,从而导致OOM的问题,设置freso代码如下;

 private  void setImg(SimpleDraweeView mImg, String url,Context context)
    {
        Uri uri = Uri.parse(url);

        ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
                .setResizeOptions(new ResizeOptions((int)(0.25 * ScreenSizeUtil.ScreenWidth(context)), (int)(0.25 * ScreenSizeUtil.ScreenHeight(context))))
                .build();

        DraweeController controller = Fresco.newDraweeControllerBuilder()
                .setOldController(mImg.getController())
                .setControllerListener(new BaseControllerListener<ImageInfo>())
                .setImageRequest(request).build();
        mImg.setController(controller);
    }

    原文作者:九宫格问题
    原文地址: https://blog.csdn.net/shb2058/article/details/79612227
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞