我正在使用Picasso库将图像加载到
ImageView中,然后使用PhotoView库向ImageView添加缩放和平移等.
但是当毕加索第一次加载图像时,它会显示如下图像:
但是,一旦我触摸图像,它就会正确放置
我的主要活动:
http://pastebin.com/5H4zAgH
我正在使用的库:
> http://square.github.io/picasso/
> https://github.com/chrisbanes/PhotoView
解决方法
当我一起使用Picasso和Photoview时,我的错误图像存在同样的问题.
为了解决这个问题,我所做的是在使用Picasso加载图像时使用回调(使用in(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);
我希望这有帮助.问候.