2

I have NestedScrollView with some texts and because that is in CoordinatorLayout, when i scroll it to end of the NestedScrollView does not show overscroll effect, my guess is that when i reach end and try to scroll more i don't scroll nestedScrollView but i scroll CoordinatorLayout.

<android.support.design.widget.CoordinatorLayout
    android:id="@+id/activity_news_main_content"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/activity_news_appbar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/activity_news_background_height"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/activity_news_collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="top"
            android:background="@color/activity_news_collapsing_toolbar_background_color"
            app:contentScrim="@color/colorPrimary"
            app:expandedTitleMarginBottom="@dimen/activity_news_title_margin_bottom"
            app:expandedTitleMarginStart="@dimen/activity_news_title_margin_start"
            app:layout_collapseMode="pin"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                android:id="@+id/activity_news_image"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="centerCrop"
                app:layout_collapseMode="parallax"
                app:layout_collapseParallaxMultiplier="0.7"
                app:layout_scrollFlags="scroll|exitUntilCollapsed"/>

            <View
                android:layout_width="match_parent"
                android:layout_height="@dimen/activity_news_view_height"
                android:layout_gravity="bottom"
                android:background="@color/activity_news_collapsing_toolbar_background_color"/>

            <include
                android:id="@+id/app_bar"
                layout="@layout/news_app_bar"/>

        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

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

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:padding="@dimen/activity_news_padding">

                <TextView
                    android:id="@+id/activity_news_subtitle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingBottom="@dimen/activity_news_subtitle_bottom_padding"/>

                <TextView
                    android:id="@+id/activity_news_description"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"/>
            </LinearLayout>

    </android.support.v4.widget.NestedScrollView>

</android.support.design.widget.CoordinatorLayout>
ʍѳђઽ૯ท
  • 16,646
  • 7
  • 53
  • 108
Markicevic
  • 1,025
  • 9
  • 20
  • The LinearLayout in your NestedScrollView should have the height set to 'wrap_content' – Much Overflow Jan 19 '16 at 11:35
  • Still not working... – Markicevic Jan 19 '16 at 12:15
  • Actually, a quick google search gave me a bug report filed for this exact problem. If you fling up or downwards, you might sometimes see the over scroll effect. You can check the report here https://code.google.com/p/android/issues/detail?id=175720 – Much Overflow Jan 19 '16 at 12:42

1 Answers1

0

That design is wrong.

See:

<include
    android:id="@+id/app_bar"
    layout="@layout/news_app_bar"/>

You were including the layout in the CollapsingToolbarLayout which that should be in the NestedScrollView and not that CollapsingToolbarLayout.

Just do your stuffs in the NestedScrollView like this:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/activity_news_main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

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

        <!--Here is the contents-->

        <!--<LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <TextView
                android:id="@+id/activity_news_subtitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

            <TextView
                android:id="@+id/activity_news_description"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />
        </LinearLayout>-->

    </android.support.v4.widget.NestedScrollView>

    <android.support.design.widget.AppBarLayout
        android:id="@+id/activity_news_appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbarmain"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/colorPrimary"
            app:layout_collapseMode="pin"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/activity_news_collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="top"
            app:contentScrim="@color/colorPrimary"
            app:layout_collapseMode="pin"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                android:id="@+id/activity_news_image"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="centerCrop"
                app:layout_collapseMode="parallax"
                app:layout_collapseParallaxMultiplier="0.7"
                app:layout_scrollFlags="scroll|exitUntilCollapsed" />


        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>


</android.support.design.widget.CoordinatorLayout>

And read this: CollapsingToolbarLayout

CollapsingToolbarLayout is a wrapper for Toolbar which implements a collapsing app bar.

ʍѳђઽ૯ท
  • 16,646
  • 7
  • 53
  • 108
  • toolbar must be in collapsing toolbar layout so it would collapse when i scroll up, i tried it this way still no efect. – Markicevic Jan 21 '16 at 15:36
  • You can put it inside the `collapsing toolbar` that depends on you.And it's working with this design.let me know what's that layout too, or just use this base and go ahead! – ʍѳђઽ૯ท Jan 21 '16 at 15:41