如何防止在 Android Imageview 中缩放?

How do I prevent scaling in Android Imageview?(如何防止在 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 中缩放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)