ImageView с AdjustViewBounds непоследовательно отображается внутри ConstraintLayout при инфляции

Я использую RecyclerView для отображения сетки изображений. Когда изображение нажимается, фрагмент диалогового окна увеличивает версию этого изображения с разным соотношением сторон, поэтому я использую AdjustViewBounds. Изображения поступают с URL-адресов из Instagram API. Обработка изображений производится с помощью Glide.

Когда я использую другой макет или не использую макет, я не сталкиваюсь с этой проблемой. Если я использую Glide для изменения размера всех отображаемых изображений с одинаковым соотношением сторон, я также не сталкиваюсь с этой проблемой.

Наглядный пример проблемы

Расширенный вид фрагмента диалога.

<layout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools">

    <data>

        <variable
                name="url"
                type="String" />

        <variable
                name="hashTag"
                type="String" />
    </data>


    <androidx.cardview.widget.CardView
            android:id="@+id/dialog_cardView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:cardBackgroundColor="@color/EERIE_BLACK"
            app:cardCornerRadius="20dp"
            app:cardPreventCornerOverlap="true">

        <androidx.constraintlayout.widget.ConstraintLayout
                android:id="@+id/dialog_image_constraintLayout"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

            <ImageView
                    android:id="@+id/dialog_image"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginTop="48dp"
                    android:layout_marginBottom="48dp"
                    android:adjustViewBounds="true"
                    app:imageUrl="@{url}"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent"
                    tools:src="@drawable/image_2" />

            <TextView
                    android:id="@+id/textView"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="16dp"
                    android:layout_marginTop="16dp"
                    android:text="#PlaceHolderTag"
                    android:textColor="@color/BABY_POWDER"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent"
                    tools:text="#Hashtag" />

        </androidx.constraintlayout.widget.ConstraintLayout>
    </androidx.cardview.widget.CardView>
</layout>

person xZ4FiRx    schedule 27.09.2019    source источник
comment
Установите соотношение для просмотра изображения   -  person Jaymin    schedule 27.09.2019
comment
@Jaymin Не все изображения имеют одинаковое соотношение. Я хочу, чтобы ImageView соответствовал изображению.   -  person xZ4FiRx    schedule 27.09.2019


Ответы (1)


если вы хотите ImageView match_parent или полный, вы можете добавить

android:scaleType="fitXY"
person indra lesmana    schedule 27.09.2019