【发布时间】:2020-06-30 15:27:15
【问题描述】:
我正在回收站视图中的网格布局图像库中工作。 回收站查看项目代码为
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:background="@android:color/holo_red_light"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/imageView"
android:adjustViewBounds="true"
app:layout_constraintDimensionRatio="9:16"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
tools:src="@drawable/test"
android:layout_width="0dp"
android:layout_height="0dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
我将 adjustViewBounds 设置为 true、false、缩放类型所有内容,但我无法删除顶部和底部的额外视图。如何做呢。红色是布局中的额外视图。
【问题讨论】:
-
我也删除了底部约束,但没有工作
-
您的图像与网格中的单元格的纵横比不同。您将有额外的空间(就像现在一样),或者您将看到图像被裁剪而不调整单元格大小。我猜你会想要调整单元格大小。尝试将 ImageView 的高度设置为
wrap_content。 -
wrap_content 不工作
标签: android imageview android-constraintlayout