在Android中显示图像预览

时间:2012-05-17 08:59:27

标签: android image gallery

我想向用户显示手机上的图像。但我想向用户展示图像的预览。

enter image description here

当用户触摸图像时,我想显示图像的路径。

我的布局中有一个按钮。单击按钮时如何显示图像。

<?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:background="@drawable/back_default">

    <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/button_pickimage" android:id="@+id/btn_pickimage"></Button>

</LinearLayout>

3 个答案:

答案 0 :(得分:1)

答案 1 :(得分:0)

我认为你应该看看 Android GalleryAndroid GridView

单击按钮时,只需将Intent指向GridView。

关于单击图像以显示其路径是另一回事。您可以构建自定义布局或Toast或其他任何东西来满足您显示路径的需要。在图像上放置onClick侦听器即可。

答案 2 :(得分:0)

据我了解,您希望首先显示缩略图图像(如链接中所示),然后点击任意图像,可以在不同视图中放大该特定图像,

然后简单的方法..

1.Make two separate activity for preview and large image
2. Store all your image in a array(If you have diff images for preview and large image then place accordingly).
3. set id for each imageview (In preview mode)
4. send id of selected imageview to next activity using putextra
5. Use id to access the array