Android NestedScrollView fillViewport stretching incorrectly

13,806

Solution 1

I have used it like this:

<android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:fillViewport="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" 
            ...

Maybe the difference is that the linear layout has a specified orientation or maybe I am using a more updated library com.android.support:design:23.1.0 and that is the reason why I cant reproduce your problem.

Solution 2

Maybe I am too late for this, but the way I solved this was to replace NestedScrollView child (in your case, RelativeLayout) margin with padding. If that didn't work, also try replacing RelativeLayout child margin with padding.

Let me know if that works!

Share:
13,806
Joe
Author by

Joe

Updated on June 20, 2022

Comments

  • Joe
    Joe almost 2 years

    I am trying to use the new NestedScrollView from the support libraries. I want the scrollable content to expand to match parent if it is smaller. I see that to do that, I'm supposed to add fillViewport=true to the NestedScrollView. When I do this, my scrollable content doesn't stretch vertically, it instead stretches horizontally off-screen. enter image description here

    The layout card_movie simply has a RelativeLayout with some TextViews and one ImageView inside it. Nothing special. enter image description here

  • worked
    worked over 8 years
    Boom! That's what I'm talking about!