Iam在回收者视图中的网格布局图像库中工作。回收者视图的项目代码为
<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,缩放所有内容,但是我无法删除顶部和底部的多余视图。怎么做到呢。红色是布局中的额外视图。
最后,我在堆栈溢出中找到了答案,根据视图创建了可伸缩的位图。代码在下面发布...