图片一直闪现,换成小图后好了
9张图,一直循环闪现,log显示一直在请求图片地址,换成小图后正常,是不是图片太大的缘故 @jeasonlzy
同问,我的是三张小图一直闪烁,有时候会前两张闪烁,第三张正常,点击放大图片倒是没有
@tardisTao @jeasonlzy 小图还是太大了吧
@stormlei 我小图、大图用的是同一张图片
@stormlei @tardisTao @jeasonlzy 大家最后怎么解决这个问题的
@395193253 @jeasonlzy 换成小图啊,不过多大的算小,还没测试
@stormlei 好呢!“不过多大的算小,还没测试”。换小图试下,谢谢
在NineGridView中的onLayout()方法中加个
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { if(changed){ if (mImageInfo == null) return; int childrenCount = mImageInfo.size(); for (int i = 0; i < childrenCount; i++) { ImageView childrenView = (ImageView) getChildAt(i); if (mImageLoader != null) { //改动ImageLoder mImageLoader.onDisplayImage(getContext(), childrenView, mImageInfo.get(i).thumbnailUrl,null); } int rowNum = i / columnCount; int columnNum = i % columnCount; int left = (gridWidth + gridSpacing) * columnNum + getPaddingLeft(); int top = (gridHeight + gridSpacing) * rowNum + getPaddingTop(); int right = left + gridWidth; int bottom = top + gridHeight; childrenView.layout(left, top, right, bottom); } } }
加了这个判断if(changed){}初步可以解决
在NineGridView中的onLayout()方法中加个
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { if(changed){ if (mImageInfo == null) return; int childrenCount = mImageInfo.size(); for (int i = 0; i < childrenCount; i++) { ImageView childrenView = (ImageView) getChildAt(i); if (mImageLoader != null) { //改动ImageLoder mImageLoader.onDisplayImage(getContext(), childrenView, mImageInfo.get(i).thumbnailUrl,null); } int rowNum = i / columnCount; int columnNum = i % columnCount; int left = (gridWidth + gridSpacing) * columnNum + getPaddingLeft(); int top = (gridHeight + gridSpacing) * rowNum + getPaddingTop(); int right = left + gridWidth; int bottom = top + gridHeight; childrenView.layout(left, top, right, bottom); } } }加了这个判断if(changed){}初步可以解决
这个是正解
Application中的家在图片这样设置,这才是正解
Glide.with(context)
.load(url)
.error(R.drawable.ic_default_image)
.placeholder(R.drawable.ic_default_image)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(imageView);