bm-x / PhotoView

图片浏览缩放控件
2.63k stars 539 forks source link

我想问问下我用Glide加载图片 在listview中点击放大的时候第一次进去位置不对 #70

Open njgghhe opened 7 years ago

njgghhe commented 7 years ago

我就是好用Demo里面那个GridView的例子,就是把GridView换成了listview 加载图片的话用Glide,第一次点进去位置会乱跑到左下角,然后点击再次进去就是显示正中央 是正常的 我就放了四个图片,每一个图片进去位置都不一样,第二次就会正常显示在中央,然后退界面后再次进来就又会出现这个情况,请问这是应该怎么解决

lodgkk commented 7 years ago

你用了Glide,因为是网络加载,开始是没有缓存,导致位置偏差,下次进去缓存了,所以正常了,我给你一个解决的方法把,希望以后有人看到可以这么做: Glide.with(BaseApplication.mContext) .load(url) .placeholder(R.color.gray) .error(R.color.gray) .into(new SimpleTarget() { @Override public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) { //在这里做处理 if (dialog != null)dialog.dismiss(); mPhotoView.setImageDrawable(resource); mBg.startAnimation(in); mBg.setVisibility(View.VISIBLE); mParent.setVisibility(View.VISIBLE); mPhotoView.animaFrom(mInfo); } });

njgghhe commented 7 years ago

好的 谢谢谢谢 请问 if (dialog != null)dialog.dismiss();这一句 我原本里面是没有的 这是是根据什么来判断的

bm-x commented 7 years ago

dialog这句可以忽略,他应该想表达的是into(new SimpleTarget() {public void onResourceReady(}

njgghhe commented 7 years ago

哦哦 这样啊 我在试试 有结果就发出来

njgghhe commented 7 years ago

好了 这样是可以的 谢谢 非常感谢!!

loryrichie commented 6 years ago

正好解决了我的问题

xvvx-Rainbowcat commented 5 years ago

确实可以用,非常感谢