[英]Full size image in ImageView
I'm trying to draw an image in an ImageView, but i want it to be unscaled, with scrollbars as necessary. 我正在尝试在ImageView中绘制图像,但我希望它不需要缩放,必要时使用滚动条。 How can I accomplish this?
我怎么能做到这一点? Right now I just have a drawable set as the android:src of the ImageView in the XML.
现在我只有一个drawable set作为XML中ImageView的android:src。 This autoscales the image to fit the screen width.
这会自动缩放图像以适应屏幕宽度。
I read that this might be because of the compatibility mode (developing for 1.5, testing on 2.1), but then I added 我读到这可能是因为兼容模式(开发1.5,测试2.1),但后来我补充说
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4" />
to my manifest, and nothing changed. 我的清单,没有任何改变。
Any clues? 有线索吗?
-- -
Edit: I used android:scaleType="center"
on the ImageView, and this displays the full image (can't believe I didn't see this before), but I still only get a vertical scrollbar. 编辑:我在ImageView上使用了
android:scaleType="center"
,这显示了完整的图像(不能相信我之前没有看到过),但我仍然只得到一个垂直滚动条。 Using android:scrollbars="horizontal"
on the ScrollView that's wrapped around the ImageView (obviously) hides the vertical scrollbar, but doesn't show a horizontal scrollbar... 在ScrollView上使用
android:scrollbars="horizontal"
,它围绕着ImageView(显然)隐藏了垂直滚动条,但没有显示水平滚动条......
This worked for me (using an HorizontalScrollView inside a ScrollView): 这对我有用(在ScrollView中使用HorizontalScrollView):
<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>
检查这个例子有帮助
I believe you have to size the ImageView to the size of the Bitmap and place the ImageView into a ScrollView. 我相信您必须将ImageView的大小调整为Bitmap的大小,并将ImageView放入ScrollView中。 But you may run into memory issues trying to display a large image.
但是,您可能会遇到尝试显示大图像的内存问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.