【发布时间】:2012-07-13 08:49:14
【问题描述】:
我想知道为我的应用创建照片库的最佳方式是什么。我从 RSS 提要中获取图片,我想全屏显示它们。我应该使用什么?我尝试使用 ImageView,但图像的大小调整不当(它们不保持原始尺寸)
我用这个答案来实现我的画廊:Android Gallery fullscreen
谢谢
编辑:
这是 XML 布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
android:id="@+id/galleryPager"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</android.support.v4.view.ViewPager>
</LinearLayout>
这是我在适配器中用来加载图像的代码:
@Override
public Object instantiateItem(View collection, int position) {
ImageView imageView = new ImageView(context);
imageView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
ImageDownloader.getInstance().download(gallery.get(position), ImageFormat.CONTENT_316, imageView);
((ViewPager) collection).addView(imageView, 0);
return imageView;
}
【问题讨论】:
-
其他人留下了评论建议,该评论显然已被删除。
标签: android imageview photo-gallery