【问题标题】:Full size image in ImageViewImageView 中的全尺寸图像
【发布时间】:2010-03-29 11:12:11
【问题描述】:

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

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

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

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

有什么线索吗?

--

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

【问题讨论】:

    标签: android scaling imageview


    【解决方案1】:

    这对我有用(在 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>
    

    【讨论】:

      【解决方案2】:

      检查这个example 它有帮助

      【讨论】:

      • 完美!嗯,完全适应我的需要! :)
      • 提供的链接无效!!
      【解决方案3】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-05-10
        • 1970-01-01
        • 2018-02-21
        • 2014-11-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多