我正在加载图像到ImageView与毕加索图书馆,然后使用PhotoView库添加缩放和平移等..到ImageView。毕加索和PhotoView库加载图像到ImageView怪异
但是,当毕加索加载了图像,第一次它显示的图片是这样的:
但是,只要我触摸图像它正确的地方
但是,如果我关闭我的应用程序,它突然不再显示图像,并且不会。
我的MainActivity: http://pastebin.com/5H4zAgH
我使用的库:
我正在加载图像到ImageView与毕加索图书馆,然后使用PhotoView库添加缩放和平移等..到ImageView。毕加索和PhotoView库加载图像到ImageView怪异
但是,当毕加索加载了图像,第一次它显示的图片是这样的:
但是,只要我触摸图像它正确的地方
但是,如果我关闭我的应用程序,它突然不再显示图像,并且不会。
我的MainActivity: http://pastebin.com/5H4zAgH
我使用的库:
我用毕加索,当曾与错位的图像同样的问题Photoview在一起。
为了解决这个问题,我所做的是使用into(view, callback)
而不是仅仅使用into(view)
加载与毕加索的图像时使用回调。一旦图像加载成功,我实例化PhotoViewAttacher对象或调用方法update()
。
在这里,你有代码的例子:
Callback imageLoadedCallback = new Callback() {
@Override
public void onSuccess() {
if(mAttacher!=null){
mAttacher.update();
}else{
mAttacher = new PhotoViewAttacher(mImageView);
}
}
@Override
public void onError() {
// TODO Auto-generated method stub
}
};
Picasso.with(mContext)
.load(mImageUrl)
.into(mImageView,imageLoadedCallback);
我希望这有助于。问候。
我也有同样的问题。我通过使用PhotoView
而不是ImageView
解决了这个问题,并从我的代码中删除了PhotoViewAttacher
。
在布局文件(如果你使用的布局):
<uk.co.senab.photoview.PhotoView
android:id="@+id/your_photo_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
... />
并在代码:
PhotoView photoView = (PhotoView) findViewById(R.id.your_photo_view);
Picasso.with(context)
.load(file)
...
.into(photoView);
现在一切都必须是正确的(至少对我来说是!);
正是我在找的东西! – dasmikko
如果我每次重新创建联接器而不是更新,它似乎会更好地工作。 –
如果我想使用viewpager怎么办? – randy