2012-05-17 192 views
1

我想將手機中的圖像顯示給用戶。但我想向用戶展示圖像的預覽。在Android中顯示圖片預覽

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> 

回答

0

我想你應該看看 Android GalleryAndroid GridView

當您單擊該按鈕只是把意圖直接到GridView控件。

而關於點擊圖片以顯示其路徑是另一回事。你可以建立一個自定義的佈局或吐司或任何符合你的需要顯示路徑。在圖像上放置onClick監聽器。

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