NestedScrollView 内的子级未覆盖整个屏幕高度

Posted

技术标签:

【中文标题】NestedScrollView 内的子级未覆盖整个屏幕高度【英文标题】:Child inside NestedScrollView not cover full height of screen 【发布时间】:2017-08-17 05:28:15 【问题描述】:

我在我的片段中使用 NestedScrollView。在我的 xml 中的 RelativeLayout 但它没有覆盖整个屏幕高度。

下面是我的代码 -

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:fitsSystemWindows="true"
android:background="@color/black"
android:layout_
android:layout_>

<RelativeLayout
    android:background="@color/red_error_color"
    android:layout_
    android:layout_>


</RelativeLayout>
</android.support.v4.widget.NestedScrollView>

运行代码时,只有黑色背景可见,但不是红色,因为我的子视图背景是红色的。

提前致谢

【问题讨论】:

【参考方案1】:

尝试在你的nestedscrollview上添加这行代码

android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"

删除:

android:fitsSystemWindows="true"

【讨论】:

我想在更一般的情况下 android:fillViewport="true" 就足够了。 (为我工作)

以上是关于NestedScrollView 内的子级未覆盖整个屏幕高度的主要内容,如果未能解决你的问题,请参考以下文章

NestedScrollView 内的 RecyclerView ScrollListener

无法滚动到 NestedScrollView 内的 RecyclerView 中的项目

NestedScrollView 内的回收器视图导致滚动从中间开始

NestedScrollView 内的 RecyclerView :使水平滚动更容易

ConstraintLayout 内的 NestedScrollView 不可滚动

NestedScrollview 内的 RecyclerView 滚动不顺畅