I have a carousel banner and I have the requirement the images to cover all the layout and be displayed the same irrespective of device resolution. Below is the original image, device screenshot of correct use and lastly, device screenshot of wrong use
As you can see in the last image, the circle on the right upper part of the image becomes oval shaped, which is not the case.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#232323">
<ImageView
android:id="@+id/advert_carousel_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY" />
</androidx.constraintlayout.widget.ConstraintLayout>
Image is set using Glide
Glide
.with(mContext)
.load(img)
.into(advertCarouselBackground);
Any ideas on how the original image can be displayed without distortion independently of device resolution? I have tried some solutions, like converting the image to bitmap, setting width and height programmatically, calculating aspect ratio, etc, but nothing worked so far.


