将放大/缩小添加到图像的列表视图



我有一个片段,其中包含一个ListView,每次启动片段时都会替换多个图像(7-10)。

我尝试使用不同的库进行缩放,但ListView不会显示,因为我将不得不用库的定义ImageView替换ImageView

如何为这些图像添加放大/缩小?

编辑:我想在每次加载时向包含不同数量图像的ListView添加放大/缩小,正如我的问题所述。

编辑2:这是我Custom Adapter getview方法。如何在其中附加 PhotoViewAttacher?

public View getView(int position, View convertView, ViewGroup parent) {
    View iv = convertView;
    ViewHolder holder = null;
    if (iv == null) {
        LayoutInflater inflater = ((Activity) context).getLayoutInflater();
        iv = inflater.inflate(layoutResourceId, parent, false);
        holder = new ViewHolder();
        holder.image = (ImageView) iv.findViewById(R.id.imagview);
        iv.setTag(holder);
    } else {
        holder = (ViewHolder) iv.getTag();
    }
    Picasso.with(context)
            .load((Integer) data.get(position))
            .resize(999, 720)
            .onlyScaleDown()
            .centerInside()
            .into(holder.image);
    return iv;
}
static class ViewHolder {
    ImageView image;
    PhotoViewAttacher mAttacher;
}

}

这就是我让它工作的方式

导入照片视图后

在布局文件中(如果使用布局):

<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); 

谢谢大家抽出宝贵时间。

而不是在BaseAdaptergetView列表项中添加简单的ImageView触摸图像视图

最新更新