测试中发现:某平板只能显示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);
}