简体   繁体   English

如何在毕加索库中实现双指缩放?

[英]How to implement Pinch Zoom in Picasso library?

I'm using Picasso library in my current project http://square.github.io/picasso/ .我在我当前的项目http://square.github.io/picasso/ 中使用 Picasso 库。 Everything is working fine but I just can't figure out how to implement Pinch Zoom for all images that are being loaded from URL.一切正常,但我无法弄清楚如何为从 URL 加载的所有图像实现捏缩放。 To be honest I don't even know where to place the onClickListener .老实说,我什至不知道在哪里放置onClickListener My application have several fragments and each of them have 2 Tabs , first Tab has a ListView and the second tab has some pictures displayed in a GridView :我的应用程序有几个片段,每个片段都有 2 个Tabs ,第一个Tab有一个ListView ,第二个tab有一些显示在GridView图片:

Bmw.java宝马

public class Bmw2 extends Fragment {

    @Override

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(com.zenyt.R.layout.bmw2, container, false);

        GridView gv = (GridView) rootView.findViewById(R.id.grid_view);
        gv.setAdapter(new com.zenyt.SampleGridViewAdapter(getActivity()));
        gv.setOnScrollListener(new SampleScrollListener(getActivity()));


        return rootView;
    }

SampleGridViewAdapter示例网格视图适配器

public final class SampleGridViewAdapter extends BaseAdapter {
    private final Context context;
    private final List<String> urls = new ArrayList<String>();

    public SampleGridViewAdapter(Context context) {
        this.context = context;

        // Ensure we get a different ordering of images on each run.
        Collections.addAll(urls, Data.URLS);
        Collections.shuffle(urls);

    }

    @Override public View getView(int position, View convertView, ViewGroup parent) {
        SquaredImageView view = (SquaredImageView) convertView;
        if (view == null) {
            view = new SquaredImageView(context);
            view.setScaleType(CENTER_CROP);
        }

        // Get the image URL for the current position.
        String url = getItem(position);

        // Trigger the download of the URL asynchronously into the image view.
        Picasso.with(context) //
                .load(url) //
                .placeholder(R.drawable.placeholder) //
                .error(R.drawable.error) //
                .fit() //
                .tag(context) //
                .into(view);

        return view;
    }

    @Override public int getCount() {
        return urls.size();
    }

    @Override public String getItem(int position) {
        return urls.get(position);
    }

    @Override public long getItemId(int position) {
        return position;
    }
}

Data.java数据.java

final class Data {
    static final String BASE = "http://www.hdcarwallpapers.com/walls/";
    static final String BASE2 = "http://www3.cellsea.com//content/wallpaper/";
    static final String EXT = ".jpg";
    static final String[] URLS = {
            BASE + "prior_design_audi_r8_gt850-wide" + EXT,
            BASE + "2015_audi_rs6_avant_exclusive-wide" + EXT,
            BASE + "2015_audi_tt_coupe_quattro-wide" + EXT,
            BASE + "2015_audi_tt_coupe_quattro-wide" + EXT,
            BASE + "2014_audi_prologue_concept_4-wide" + EXT,
            BASE2 + "2010/WP4ce483c6efa9d" + EXT,

    };

    private Data() {
        // No instances.
    }
}

Sorry for my english.对不起我的英语不好。

Picasso library is used only to load the images from network. Picasso 库仅用于从网络加载图像。

You need to address your request with other library such as PhotoView or any other that support actions on images.您需要使用其他库(例如PhotoView或任何其他支持图像操作的库)来解决您的请求。

PhotoViewAttacher photoViewAttacher;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


    ImageView imageView = (ImageView) findViewById(R.id.imageView);

    Picasso.with(this)
            .load("http://easyway-ev.xyz/images/1.png")
            .into(imageView);//Regular
    photoViewAttacher = new PhotoViewAttacher(imageView);}

this is my answer, I take Picasso, and after i used photoView, also this video how sync photoView enter link description here I hope this help you!这是我的答案,我拿了毕加索,在我使用了 photoView 之后,还有这个视频如何同步 photoView在这里输入链接描述我希望这对你有帮助!

Just use TouchImageView instead of ImageView.只需使用 TouchImageView 而不是 ImageView。

https://github.com/MikeOrtiz/TouchImageView https://github.com/MikeOrtiz/TouchImageView

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM