【发布时间】:2020-05-27 11:55:51
【问题描述】:
我有两个相同的约束布局,除了一个是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