NestedScrollView中的子级无法覆盖整个屏幕高度 [英] Child inside NestedScrollView not cover full height of screen

查看:93
本文介绍了NestedScrollView中的子级无法覆盖整个屏幕高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using NestedScrollView in my fragment. In my xml inside a RelativeLayout but it is not covering full height of screen.

下面是我的代码-

<?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>

运行代码时,只有黑色背景可见,而由于我的子视图背景为红色,所以看不到红色.

when run the code only black background is visible but not red as my child view background is red.

预先感谢

推荐答案

尝试在您的nestedscrollview中添加这一行代码

Try to add this line of code on your nestedscrollview

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

删除:

android:fitsSystemWindows="true"

这篇关于NestedScrollView中的子级无法覆盖整个屏幕高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆