ImageView的配合不拉伸的图像 [英] ImageView fit without stretching the image
问题描述
是有可能,我的的ImageView
将适合所有屏幕尺寸,从而使图像显得捉襟见肘?
我尝试了所有类型的规模与它 FILL_PARENT
> WRAP_CONTENT
但仍。如果图像是不小的,它只是看起来拉长。
例如:
< ImageView的
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:scaleType =centerInside
机器人:adjustViewBounds =真
机器人:背景=@绘制/背景/>< ImageView的
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:scaleType =fitXY
机器人:adjustViewBounds =真
机器人:背景=@绘制/背景/>
2,这些适合的宽度,但图像被拉伸..但是当我将其更改为src中的形象只是居中和小。
有没有内置的规模型,使的ImageView
来自动的高档形象的和的保持它的长宽比不变。 ,做倍增唯一的规模类型是 fitXY
,这将不尊重宽高比,因为你发现你自己了。
话虽这么说,这个话题已经被参观了不止一次。看看一些类似的问题所提出的建议的:
- ImageView一个尺寸适合的自由空间和第二评估,以保持纵横比
- Fit图像插入ImageView的,保持宽高比,然后调整ImageView的图像尺寸是多少?
- Resizing的ImageView以适应宽高比
我sure'll是堆越多,所以它使用搜索框的顶部可能值得的。
is it possible that my ImageView
will fit to all screen sizes without the image look stretched?
i tried all scale types changing it to background and src with fill_parent
> wrap_content
but still. if the image is not smaller it just looks stretched..
example:
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="centerInside"
android:adjustViewBounds="true"
android:background="@drawable/background" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:background="@drawable/background" />
these 2 fits the width but the image is stretched.. but when i change it to src the image is just centered and small.
There is no built-in scale type that allows the ImageView
to automatically upscale the image and keep its aspect ratio intact. The only scale type that does upscaling is fitXY
, which won't respect the aspect ratio, as you found out yourself too.
That being said, this topic has already been visited more than once. Have a look at some of the proposed suggestions for similar questions:
- ImageView one dimension to fit free space and second evaluate to keep aspect ration
- Fit image into ImageView, keep aspect ratio and then resize ImageView to image dimensions?
- Resizing ImageView to fit to aspect ratio
I'm sure'll be heaps more, so it might worth using the search box at the top.
这篇关于ImageView的配合不拉伸的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!