更新时间:2023-08-27 21:15:58
不使用任何自定义类或库:
Without using any custom classes or libraries:
<ImageView
android:id="@id/img"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitCenter" />
scaleType="fitCenter"
(省略时默认)
scaleType="centerInside"
src
的固有宽度小于父宽度src
的固有宽度大于父级宽度src
is smaller than parent widthsrc
is larger than parent width使用 android:src
或 ImageView.setImage*
方法没关系,关键可能是 adjustViewBounds
.
It doesn't matter if you use android:src
or ImageView.setImage*
methods and the key is probably the adjustViewBounds
.