初开发app,遇到问题,特此记录。
今天使用pdfRenderer配合recycleView制作简单的pdf阅读,但是发现item的ImageView刚开始是好的,各个item的布局紧凑。如图。
但是滑动之后,item的间距变大。如图。
**最后发现是因为item的布局的根layout的height是match_parent;改为wrap_content就可以了。
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>