Android的Gallery控件:AndroidTouchGallery
efbb
9年前
使用viewpager实现的Android的Gallery控件。通过指定图片URL实现允许捏缩放和拖动。
- Make import library folder into your IDE.
- Make sure, that AndroidTouchGallery has included in your project as library. Check project properties, and make sure checkbox "Is library" is checked.
- 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" />
- 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);