[英]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 Gallery和Android 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.