How do I prevent scaling in Android Imageview?(如何防止在 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 中缩放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何防止在 Android Imageview 中缩放?
基础教程推荐
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
