PhotoVIewAttacher 和 Picasso 在片段更改时取消缩放图片

PhotoVIewAttacher and PIcasso unzoom picture on fragment change

好的,所以,我已经将 photoviewattacher 和 picasso 实现到一个图像视图中,当我滑动图像 1 将图片更改为图像 2 并尝试返回时,图像 1 仍然在我离开的地方缩放。如何解决这个问题?这是代码:

private PhotoViewAttacher mAttacher;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout resource that'll be returned
    View rootView = inflater.inflate(R.layout.fragment_katalozi_slike, container, false);

    // Get the arguments that was supplied when
    // the fragment was instantiated in the
    // CustomPagerAdapter
    Bundle args = getArguments();
    final ImageView imageView = (ImageView) rootView.findViewById(R.id.imageViewAdapterZaListanjeKataloga);
    mAttacher = new PhotoViewAttacher(imageView);
    Callback imageLoadedCallback = new Callback() {

        @Override
        public void onSuccess() {
            if (mAttacher != null) {
                mAttacher.update();
            } else {
                mAttacher = new PhotoViewAttacher(imageView);
            }
        }

        @Override
        public void onError() {
            // TODO Auto-generated method stub

        }
    };

    Picasso.with(getActivity()).load(args.getString("url")).placeholder(R.drawable.load).error(R.drawable.error).into(imageView, imageLoadedCallback);

    ((TextView) rootView.findViewById(R.id.brojStranaNaSliciKataloga)).setText(String.valueOf(args.getInt("trenutnaStranica")) + "/" + String.valueOf(args.getInt("konacanBrojStranica")));
    ImageButton imageButton = (ImageButton) rootView.findViewById(R.id.shareButtonKatalozi);
    ImageButton locirajMe = (ImageButton) rootView.findViewById(R.id.locirajButtonKatalozi);
    final String zaShare = args.getString("linkKataloga");

    locirajMe.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getLatLng(String.valueOf(Static.prodavci.getId()));
        }
    });

    imageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            shareIt(zaShare);
        }
    });

    return rootView;
}

你做

@Override
public void onDestroyView() {
    super.onDestroyView();
    mAttacher.cleanup();

}

对我有用。