我如何prevent比例在Android中的ImageView?

编程入门 行业动态 更新时间:2024-10-10 00:27:52
本文介绍了我如何prevent比例在Android中的ImageView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个形象,是480像素×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).

有没有一种方法,以prevent它扩展到合适?

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:

Use ScaleType.CENTER, like this in XML:

android:scaleType="center"

这将居中图像中的观点,但不进行任何缩放

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

在这里阅读更多:developer.android/reference/android/widget/ImageView.ScaleType.html

(这是顺便把第一次打在谷歌搜索ImageView的规模)

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

更多推荐

我如何prevent比例在Android中的ImageView?

本文发布于:2023-06-05 22:04:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/529895.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:比例   prevent   ImageView   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!