调整 ImageView 容器的大小以完全匹配放置在其中的图像
Resize ImageView container to exactly match an image that gets placed inside of it
我有一个 ImageView
,设置为 match_parent
的宽度、wrap_content
的高度和 centerInside
的比例类型。然后,在代码中,我在其中放置了一个水平矩形位图,该位图正确填充了宽度。然而,imageview 容器是一个正方形,因此它在垂直方向上超出了位图的边界。如何调整图像视图的大小,使其与位图的大小完全匹配?
在 ImageView
中使用 adjustViewBounds="true"
使其适合所含图像的大小。
我有一个 ImageView
,设置为 match_parent
的宽度、wrap_content
的高度和 centerInside
的比例类型。然后,在代码中,我在其中放置了一个水平矩形位图,该位图正确填充了宽度。然而,imageview 容器是一个正方形,因此它在垂直方向上超出了位图的边界。如何调整图像视图的大小,使其与位图的大小完全匹配?
在 ImageView
中使用 adjustViewBounds="true"
使其适合所含图像的大小。