Child inside NestedScrollView does not cover the entire height of the screen

I am using NestedScrollView in my fragment. In my xml, inside a RelativeLayout, but it does not cover the entire height of the screen.

Below is my code -

<?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 you run the code, only a black background is displayed, but not red, since the background of my child view is red.

Thanks in advance

+6
source share
1 answer

Try adding this line of code to your nestedscrollview

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

Delete:

android:fitsSystemWindows="true"
+22
source

Source: https://habr.com/ru/post/1015993/


All Articles