ImageView的配合不拉伸的图像 [英] ImageView fit without stretching the image

查看:439
本文介绍了ImageView的配合不拉伸的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是有可能,我的的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 ,这将不尊重宽高比,因为你发现你自己了。

话虽这么说,这个话题已经被参观了不止一次。看看一些类似的问题所提出的建议的:

我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:

I'm sure'll be heaps more, so it might worth using the search box at the top.

这篇关于ImageView的配合不拉伸的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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