3

I have a AppBarLayout with a NestedScrollView. I am trying to make it display correctly and have a fling effect when it is displayed.

Originally I had this layout:

 <FrameLayout>
    <android.support.design.widget.CoordinatorLayout>
        <android.support.design.widget.AppBarLayout>
            <android.support.design.widget.CollapsingToolbarLayout>
                ...collapsing content
                <android.support.v7.widget.Toolbar/>
            </android.support.design.widget.CollapsingToolbarLayout>
        </android.support.design.widget.AppBarLayout>
        <android.support.v4.widget.NestedScrollView>
            ...scrolling content
        </android.support.v4.widget.NestedScrollView>
    </android.support.design.widget.CoordinatorLayout>
</FrameLayout>

(with the NestedScrollView outside the AppBarLayout) It worked well but I could not fling the content when scrolling.

I used the advice in the accepted answer here, using the layout pattern in the answer referenced by the accepted one and moved the content inside the AppBarLayout. It now flings nicely, but the content contained in the NestedScrollView is cut off at the height of the screen. As you begin to scroll up you immediately see the end of the views despite the content being much longer.

My current Layout is this:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
             xmlns:app="http://schemas.android.com/apk/res-auto"
             android:orientation="vertical"
             android:layout_width="match_parent"
             android:layout_height="wrap_content">
    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
            android:layout_height="wrap_content">
            <android.support.design.widget.CollapsingToolbarLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_scrollFlags="scroll|enterAlways">
                <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:minHeight="?attr/actionBarSize"
                    app:layout_collapseMode="pin"
                    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
                    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
            </android.support.design.widget.CollapsingToolbarLayout>
            <android.support.v4.widget.NestedScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"
                >
            ... textviews etc
            </android.support.v4.widget.NestedScrollView>
        </android.support.design.widget.AppBarLayout>
    </android.support.design.widget.CoordinatorLayout>
</FrameLayout>

I have tried substituting wrap_content with match_height but this doesn't seem to be the problem.

I load all the content into TextViews via a webservice call and call .RequestLayout(); on each TextView after I load the content.

edit

I have moved the NestedScrollView outside the AppBarLayou again. It flings when the AppBarLayout is collapsed, but not while it is open

Community
  • 1
  • 1
tallpaul
  • 1,220
  • 2
  • 13
  • 35
  • Have you tried not nesting it all in a FrameLayout? Also have you tried calling `Invalidate()` on the scrollview? – Cheesebaron Apr 05 '16 at 21:53
  • @Cheesebaron thanks for your reply, I have now removed the outer Framelayout now. My class makes a RESTful webservice call from `OnCreateView` for the `TextView` content. I don't actually populate them (via `TextView.Text`) until an event listener is fired signaling that the data has been received. I am calling `.RequestLayout()` and subsequently `.Invalidate()` from the end of this listener method but with no change. – tallpaul Apr 08 '16 at 12:50
  • I have just loaded a large amount of lorem ipsum into a`TextView` in the `NestedScrollView` directly in the `XML` and it is cut off just the same so I think my problem must be there. – tallpaul Apr 08 '16 at 13:02
  • Hope you have found the solution. I am also struggling with the same issue. It would be great if you can a few minutes to share your answer here. – Lalit Sharma Jul 18 '17 at 12:28

0 Answers0