das*_*kko 7 android image picasso
我正在使用Picasso库将图像加载到ImageView中,然后使用PhotoView库将缩放和平移等添加到ImageView.
但是当毕加索第一次加载图像时,它会显示如下图像:

但是,一旦触摸图像,它就会正确放置

但如果我关闭我的应用程序,它突然不再显示图像,不会.
我的主要活动:http: //pastebin.com/5H4zAgH
我正在使用的库:
Car*_*sph 26
当我一起使用Picasso和Photoview时,我对错位的图像也有同样的问题.
要解决它,我所做的是使用Picasso into(view, callback)而不是仅使用Picasso加载图像时使用回调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);
我希望这有帮助.问候.
Moh*_*min 19
我也有同样的问题.我通过使用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);
现在一切都必须正确(至少对我来说是这样!);
| 归档时间: | 
 | 
| 查看次数: | 12327 次 | 
| 最近记录: |