我在当前项目http://square.github.io/picasso/中使用Picasso库。一切正常,但我无法弄清楚如何为从URL加载的所有图像实现Pinch Zoom。说实话,我甚至不知道放置onClickListener
的位置。
我的应用程序有几个片段,每个片段有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
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.
}
}
抱歉我的英文。
答案 0 :(得分:8)
Picasso库仅用于从网络加载图像。
您需要使用其他库(例如PhotoView)或任何其他支持图片操作的库来解决您的请求。
答案 1 :(得分:3)
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);}
这是我的答案,我拿毕加索,在我使用photoView之后,这个视频也是如何同步photoView enter link description here 我希望这能帮到你!
答案 2 :(得分:1)
只需使用TouchImageView而不是ImageView。