Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/217.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 充气时,带adjustViewBounds的ImageView在ConstraintLayout内部显示不一致_Android_Imageview_Android Constraintlayout_Androidx - Fatal编程技术网

Android 充气时,带adjustViewBounds的ImageView在ConstraintLayout内部显示不一致

Android 充气时,带adjustViewBounds的ImageView在ConstraintLayout内部显示不一致,android,imageview,android-constraintlayout,androidx,Android,Imageview,Android Constraintlayout,Androidx,我正在使用RecyclerView显示图像网格。当点击一个图像时,一个对话框片段会放大该图像的一个较大版本,其纵横比会发生变化,这就是我使用adjustViewBounds的原因。这些图像来自Instagram API的URL。正在使用Glide进行图像处理 当我使用不同的布局或没有布局时,我不会遇到这个问题。如果我使用Glide来调整显示的所有图像的大小,使其具有相同的纵横比,那么我也不会遇到这个问题 问题的视觉效果 对话框视图 <layout xmlns:android="http:/

我正在使用RecyclerView显示图像网格。当点击一个图像时,一个对话框片段会放大该图像的一个较大版本,其纵横比会发生变化,这就是我使用adjustViewBounds的原因。这些图像来自Instagram API的URL。正在使用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>

如果希望ImageView匹配父级或完整级, 你可以加上

android:scaleType="fitXY"

设置图像的比例view@Jaymin这些图像的比例不尽相同。我希望ImageView与图像匹配。