0

我正在尝试创建一个显示从 url 获得的图像的活动。我希望图像的宽度适应屏幕,但图像的高度可以比屏幕长,这样图像就可以滚动(垂直)。首先,我显示了一个可绘制文件夹中的图像,它使用以下代码:

<ScrollView
    android:layout_width="fill_parent"
    android:id="@+id/scrollView1"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:scrollbarAlwaysDrawVerticalTrack="true">
    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal">



        <ImageView

            android:src="@drawable/programme"
            android:layout_height="wrap_content"
            android:id="@+id/imageView2"
            android:layout_width="wrap_content"
            android:scaleType="fitStart"></ImageView>
    </LinearLayout>
</ScrollView>

我得到了我想要的:http: //i.stack.imgur.com/imPkZ.png

但现在我希望图像从 URL 收费,所以我使用了 ion 库:

Ion.with(imageView)

            .load("http://...");

图像加载,但它不再可滚动并且无法按需要显示。 http://i.gyazo.com/704324724364235bbe417d5447265c42.png

你有什么解决办法吗?谢谢

4

1 回答 1

0

我通过在 ScrollView、ImageView 和 LinearLayout 中设置 android:layout_width="match_parent" 并为 ImageView 设置 android:adjustViewBounds="true" 找到了解决方案,如下所示:

<ScrollView
    android:layout_width="match_parent"
    android:id="@+id/scrollView1"
    android:layout_height="wrap_content"
    android:scrollbarAlwaysDrawVerticalTrack="true">
    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:orientation="vertical">

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scaleType="fitStart"
            android:adjustViewBounds="true"/>
    </LinearLayout>
</ScrollView>
于 2015-06-02T20:14:55.587 回答