Android的Gallery控件:AndroidTouchGallery

efbb 9年前
使用viewpager实现的Android的Gallery控件。通过指定图片URL实现允许捏缩放和拖动。
  1. Make import library folder into your IDE.
  2. Make sure, that AndroidTouchGallery has included in your project as library. Check project properties, and make sure checkbox "Is library" is checked.
  3. Include GalleryViewPager in your layout xml or programmatically.
<ru.truba.touchgallery.GalleryWidget.GalleryViewPager       android:id="@+id/viewer"       android:layout_width="fill_parent"       android:layout_height="fill_parent"       />

  1. Provide one of library adapters: UrlPagerAdapter or FilePagerAdapter For example (an Activity code):
setContentView(R.layout.main);  String[] urls = {      "http://cs407831.userapi.com/v407831207/18f6/jBaVZFDhXRA.jpg",      "http://cs407831.userapi.com/v4078f31207/18fe/4Tz8av5Hlvo.jpg", //special url with error      "http://cs407831.userapi.com/v407831207/1906/oxoP6URjFtA.jpg",      "http://cs407831.userapi.com/v407831207/190e/2Sz9A774hUc.jpg",      "http://cs407831.userapi.com/v407831207/1916/Ua52RjnKqjk.jpg",      "http://cs407831.userapi.com/v407831207/191e/QEQE83Ok0lQ.jpg"  };  List<String> items = new ArrayList<String>();  Collections.addAll(items, urls);  UrlPagerAdapter pagerAdapter = new UrlPagerAdapter(this, items);    GalleryViewPager mViewPager = (GalleryViewPager)findViewById(R.id.viewer);  mViewPager.setOffscreenPageLimit(3);  mViewPager.setAdapter(pagerAdapter);

项目主页:http://www.open-open.com/lib/view/home/1430960962976