我的 ImageView
是否有可能适合所有屏幕尺寸而不会拉伸(stretch)图像?
我尝试使用 fill_parent
> wrap_content
但仍然。如果图像不小,它看起来只是被拉伸(stretch)了..
示例:
<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" />
这 2 个适合宽度,但图像被拉伸(stretch).. 但是当我将其更改为 src 时,图像只是居中且很小。
最佳答案
没有内置的缩放类型允许 ImageView
自动放大图像并保持其纵横比不变。进行放大的唯一比例类型是 fitXY
,它不会尊重纵横比,正如您自己发现的那样。
话虽如此,这个话题已经被访问过不止一次了。查看针对类似问题提出的一些建议:
- 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
我肯定会更多,因此可能值得使用顶部的搜索框。
关于android - ImageView 适合而不拉伸(stretch)图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13925530/