gpt4 book ai didi

android - ScrollView 内的 RecyclerViews 正在切断最后一项

转载 作者:行者123 更新时间:2023-11-29 14:12:30 24 4
gpt4 key购买 nike

我有一个 ScrollView 和一个 LinearLayout,里面有几个不同的 RecyclerView,因为我从不同的来源加载数据。

<?xml version="1.0" encoding="utf-8"?>    
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<android.support.v7.widget.RecyclerView
android:id="@+id/posts_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:clipToPadding="false"
android:padding="10dp"
android:layout_marginTop="20dp"
android:nestedScrollingEnabled="false"/>

<android.support.v7.widget.RecyclerView
android:id="@+id/movies_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:clipToPadding="false"
android:padding="10dp"
android:layout_marginTop="20dp"
android:nestedScrollingEnabled="false"/>

<android.support.v7.widget.RecyclerView
android:id="@+id/tv_shows_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:clipToPadding="false"
android:padding="10dp"
android:layout_marginTop="20dp"
android:nestedScrollingEnabled="false"/>

<android.support.v7.widget.RecyclerView
android:id="@+id/music_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:clipToPadding="false"
android:padding="10dp"
android:layout_marginTop="20dp"
android:nestedScrollingEnabled="false"/>

<android.support.v7.widget.RecyclerView
android:id="@+id/books_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:clipToPadding="false"
android:padding="10dp"
android:layout_marginTop="20dp"
android:nestedScrollingEnabled="false"/>

</LinearLayout>

我同时使用 LinearLayoutManager 和 GridLayoutManager 来组织 recyclerviews 显示的内容。

    GridLayoutManager layoutManager = new GridLayoutManager(context, 2);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(adapter);

由于某种原因,第二个 RecycleView(带有 GridLayout)的最后一个元素被截断了。

enter image description here

而其他 RecycleView 的元素以正确的方式显示。

enter image description here

我不知道它是否重要,但在 RecycleViews 中我使用了 CardViews。

任何帮助将不胜感激,因为我正在为这个问题发疯:(


解决方案

解决方案很简单:我只是使用 NestedScrollView 而不是 ScrollView,它工作正常。

最佳答案

在这种情况下使用嵌套 ScrollView 而不是 ScrollView 。

关于android - ScrollView 内的 RecyclerViews 正在切断最后一项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49457008/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com