【问题标题】:Child inside NestedScrollView not cover full height of screenNestedScrollView 内的子级未覆盖整个屏幕高度
【发布时间】: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_width="match_parent"
android:layout_height="match_parent">

<RelativeLayout
    android:background="@color/red_error_color"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


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

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

提前致谢

【问题讨论】:

    标签: android android-scrollview android-relativelayout android-nestedscrollview


    【解决方案1】:

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

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

    删除:

    android:fitsSystemWindows="true"
    

    【讨论】:

    • 我想在更一般的情况下 android:fillViewport="true" 就足够了。 (为我工作)
    猜你喜欢
    • 2018-11-10
    • 1970-01-01
    • 1970-01-01
    • 2021-04-23
    • 1970-01-01
    • 2021-05-09
    • 1970-01-01
    • 2014-09-01
    • 1970-01-01
    相关资源
    最近更新 更多