4

我正在尝试在 ImageView 中绘制图像,但我希望它不缩放,并根据需要使用滚动条。我怎样才能做到这一点?现在我只有一个可绘制集作为 XML 中 ImageView 的 android:src。这会自动缩放图像以适应屏幕宽度。

我读到这可能是因为兼容模式(为 1.5 开发,在 2.1 上测试),但后来我添加了

<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4" />

我的清单,没有任何改变。

有什么线索吗?

--

编辑:我android:scaleType="center"在 ImageView 上使用过,它显示了完整的图像(不敢相信我以前没有看到这个),但我仍然只得到一个垂直滚动条。在包裹在 ImageView 周围的 ScrollView 上使用android:scrollbars="horizontal"(显然)隐藏了垂直滚动条,但不显示水平滚动条......

4

3 回答 3

7

这对我有用(在 ScrollView 中使用 Horizo​​ntalScrollView):

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"    
    android:layout_height="fill_parent">


    <ScrollView 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"        
    >
        <HorizontalScrollView 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

        <ImageView
            android:id="@+id/imagen"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:scaleType="center"
            />        
        </HorizontalScrollView>
    </ScrollView>
</LinearLayout>
于 2013-02-01T15:24:33.180 回答
4

检查这个例子它有帮助

于 2010-03-29T13:36:26.917 回答
2

我相信您必须将 ImageView 的大小调整为 Bitmap 的大小,并将 ImageView 放入 ScrollView。但是您可能会在尝试显示大图像时遇到内存问题。

于 2010-03-29T11:48:57.897 回答