繁体   English   中英

在Android中显示图像预览

[英]Showing an image preview in Android

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

在此处输入图片说明

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

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

<?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>

我认为您应该看看Android GalleryAndroid GridView

当您单击按钮时,只需将Intent定向到GridView。

关于单击图像以显示其路径是另一回事。 您可以构建自定义布局或Toast或满足显示路径所需的任何内容。 为此,请在图片上放置onClick侦听器。

据我了解,您想先显示缩略图(如您的链接所示),然后通过单击任意图像应在另一视图中放大该特定图像,

然后简单的方法..

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM