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