簡體   English   中英

如何使圖像可滾動? [Android平台]

[英]How can I make my image scrollable? [Android Platform]

我的圖片占用的空間比Android屏幕大得多。 我希望以全尺寸顯示圖像,並且用戶可以向任何方向移動。 就像一張地圖。

有什么建議么?

您可以使用一個免費的網絡視圖。 我不知道為什么,但是當我嘗試使用loadData方法時,它不起作用,但是使用具有空URL的loadDataWithBaseURL卻起作用了。

使用網絡視圖,您的圖像甚至可以嵌入HTML。 在下面的示例中, yourContent只是一個字符串。

例如

yourView.loadDataWithBaseURL(null, yourContent, "text/html", "UTF-8", null);

這是我看到的教程,該教程做了您所描述的內容http://www.anddev.org/scrolling_a_picture_horizo​​ntally_and_vertically-t3245.html

您可以將圖像放在ImageView中 ,然后使用ScrollViewHorizo​​ntalScrollView將其包裝,如下所示。

<HorizontalScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/yourImage"/>

    </ScrollView>

</HorizontalScrollView>

因此,您可以像地圖一樣水平和垂直地滾動它。

嘗試將滾動條與圖像放置到xml布局中

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM