Issue
I have an imageView
whos width is "match_parent"
(with some margins at each end).
Since different devices have different widths, the image is not filling the imageView but is leaving some gap at each end depending on which device am I viewing it on.
I have tried android:adjustViewBounds="true"
but this stretches the image to fill the width which distorts the content badly.
what is the correct way? should I give android multiple copies of the image with different dimensions (like the multiple drawable folders for different pixel densities) ?
update
tried scaleType to "fitXY" but this is still stretching the image not keeping aspect ratio.
this is my xml:
<ImageView
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="110dp"
android:scaleType="fitXY"
android:src="@drawable/inner_map"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/header" />
I have inserted multiple copies with different resolutions of this image into the different drawable folders if this is of any importance
Solution
<ImageView
android:id="@id/img"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop" />
https://developer.android.com/reference/android/widget/ImageView.ScaleType
Answered By - Kushan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.