android:scaleType =“ centerInside”在androidx ConstraintLayout中不被尊重?

问题描述 投票:0回答:1

我有两个相同的约束布局,除了一个是Android X,另一个是support

[Android X版本似乎不遵守比例属性android:scaleType="centerInside",因为当我将手机倾斜到横向模式时,不遵守ImageView的长宽比。

support

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#252525">


    <!-- list item -->
    <ImageView
        android:id="@+id/imageView2"

        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        android:adjustViewBounds="true"
        android:scaleType="centerInside"

        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"

        app:srcCompat="@drawable/background_listening"
        />

</android.support.constraint.ConstraintLayout>

androidx

<?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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#252525">

    <!-- list item -->
    <ImageView
        android:id="@+id/imageView2"

        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        android:adjustViewBounds="true"
        android:scaleType="centerInside"

        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"

        android:background="@drawable/ic_background_unselected"
        />

</androidx.constraintlayout.widget.ConstraintLayout>

这两种布局之间是否有明显的区别?

谢谢

android android-constraintlayout androidx
1个回答
0
投票

在androidX中删除

android:adjustViewBounds="true"

来自ImageView

© www.soinside.com 2019 - 2024. All rights reserved.