Follow this link https://stackoverflow.com/a/25069883
Without using any custom classes or libraries:
<ImageView
android:id="@id/img"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitCenter" />
scaleType="fitCenter" (default when omitted)
will make it as wide as the parent allows and up/down-scale as needed keeping aspect ratio.
scaleType="centerInside"
if the intrinsic width of src is smaller than parent width will center the image horizontally if the intrinsic width of src is larger than parent width
will make it as wide as the parent allows and down-scale keeping aspect ratio.
No comments:
Post a Comment