Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Child inside NestedScrollView not cover full height of screen

I am using NestedScrollView in my fragment. In my xml inside a RelativeLayout but it is not covering full height of 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 run the code only black background is visible but not red as my child view background is red.

Thanks in advance

like image 521
Ravi Bhandari Avatar asked Mar 24 '17 10:03

Ravi Bhandari


People also ask

What is a nested SCROLL View?

NestedScrollView is just like ScrollView, but it supports acting as both a nested scrolling parent and child on both new and old versions of Android. It is enabled by default. NestedScrollView is used when there is a need for a scrolling view inside another scrolling view.

What is fillViewPort?

android:fillViewport. Defines whether the scrollview should stretch its content to fill the viewport.

How do I use nested ScrollView in ConstraintLayout?

Just add the fillViewPort parameter to your NestedScrollView . Like that the ConstraintLayout will expand just as you'd set its width to match_parent and the RecyclerView will dynamically expand its size.

What is ScrollView explain with example?

ScrollView is used to scroll the child elements of palette inside ScrollView. Android supports vertical scroll view as default scroll view. Vertical ScrollView scrolls elements vertically. Android uses HorizontalScrollView for horizontal ScrollView.


1 Answers

Try to add this line of code on your nestedscrollview

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

Remove:

android:fitsSystemWindows="true" 
like image 117
Ncit Cosmos Avatar answered Sep 22 '22 06:09

Ncit Cosmos