卧式回收站视图,在滚动视图中具有动态内容。当内容大于视口时,垂直滚动不起作用

时间:2020-10-25 14:55:52

标签: android android-recyclerview

我在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>

我尝试了许多不同的解决方案:

  1. 将不同的ViewGroup设置为“嵌套滚动视图”子项
  2. android:nestedScrollingEnabled设置为true / false
  3. 尝试使用ConstraintLayout和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]。 一开始它是可见的,过了一会儿就看不到。

https://youtu.be/iX1jhihgNx0

0 个答案:

没有答案