我在Recycler View
中有一个水平Scroll View
。
“回收者视图”中项目的内容是动态的,这意味着它们的高度不同。
当内容超过视口的高度时,内容将被裁剪在底部。
回收站视图的布局:
<androidx.core.widget.NestedScrollView 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:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:nestedScrollingEnabled="true"
android:orientation="horizontal"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
</RelativeLayout>
</androidx.core.widget.NestedScrollView>
我尝试了许多不同的解决方案:
ViewGroup
设置为“嵌套滚动视图”子项android:nestedScrollingEnabled
设置为true / false 0dp
高度并使用app:layout_constrainedHeight="true"
除了我无法回忆起。
项目的布局如下:
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:padding="30dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constrainedHeight="true"
android:background="@android:color/black"
android:padding="20dp"
android:text="@{text}"
android:textColor="@android:color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
问题的演示:
在虚拟文本的末尾应该有一个[END]
。
一开始它是可见的,过了一会儿就看不到。