如何防止在 Android Imageview 中缩放? [英] How do I prevent scaling in Android Imageview?

查看:20
本文介绍了如何防止在 Android Imageview 中缩放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张 480 x 40 像素的图像.我想在 ImageView 中显示此图像,而无需缩放以适应.

I have an image that is 480 pixels by 40 pixels. I would like to show this image in an ImageView without having it scale to fit.

例如:如果我的屏幕只有 320 像素宽,我希望只有 320 像素的图像显示在屏幕上,而不是让它自己塞进 ImageView(即使这意味着图像的其余部分被截断).

Ex: If my screen is only 320pixels wide I would like only 320pixels of the image to show on the screen, not have it cram itself into the ImageView (even if it means that the rest of the image gets cut off).

有没有办法防止它缩放以适应?

Is there a way to prevent it from scaling to fit?

另外,我希望图像的左侧与设备屏幕的左侧对齐.

Also, I would like the left side of the image to line up with the left side of the device's screen.

谢谢

推荐答案

使用ScaleType.CENTER,像XML这样:

android:scaleType="center"

这将使图像在视图中居中,但不执行缩放"

This will "center the image in the view, but perform no scaling"

在此处阅读更多信息:http://developer.android.com/参考/android/widget/ImageView.ScaleType.html

(顺便说一句,这是谷歌搜索imageview scale"的第一次点击)

(This is by the way the first hit on googling "imageview scale")

这篇关于如何防止在 Android Imageview 中缩放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆