Alejandro Cumpa
Alejandro Cumpa

Reputation: 2363

CoordinatorLayout with NestedScroll and CollapsingToolbarLayout doesn't scroll to bottom

I am having an issue with CoordinatorLayout and CollapsingToolbarLayout, the toolbar is working fin, but when I scroll the activity to bottom, it does never get to the bottom it only gets until the 2nd row before the last one.

Is there any problem in my xml? (I am loading the text from strings.xml programmatically)

This is my Layout

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

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

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsingToolbarLayout"
            android:layout_width="match_parent"
            android:layout_height="256dp"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:contentScrim="?attr/colorPrimary"
            android:fitsSystemWindows="true">

            <ImageView
                android:id="@+id/img"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="centerCrop"
                android:src="@drawable/img_1"
                android:fitsSystemWindows="true"
                app:layout_collapseMode="parallax"/>

            <android.support.v7.widget.Toolbar
                android:id="@+id/par_toolbar"
                android:minHeight="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:layout_scrollFlags="scroll|exitUntilCollapsed"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                >
                <TextView
                    android:id="@+id/title"
                    android:textSize="17sp"
                    android:text="@string/app_toolbar_title"
                    android:textColor="@color/Blanco"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />

            </android.support.v7.widget.Toolbar>

        </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"
        android:layout_gravity="fill_vertical"
        android:background="@color/background"
        android:paddingBottom="32dp"
        android:paddingRight="32dp"
        android:paddingLeft="32dp"
        android:fillViewport="true"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">
        <LinearLayout
            android:layout_width="match_parent"
            android:paddingTop="32dp"
            android:layout_height="match_parent"
            android:background="@color/background"
            android:orientation="vertical">

            <TextView
                android:id="@+id/txt_paragraph_title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/app_name"
                android:textColor="@color/black"
                android:layout_marginBottom="5dp"
                android:textStyle="bold"
                android:textSize="18sp" />


            <TextView
                android:id="@+id/txt_paragraph"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textSize="16sp"
                android:text="@string/history1"
                android:textColor="@color/black"/>

        </LinearLayout>
    </android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>

Upvotes: 0

Views: 851

Answers (1)

DmitryArc
DmitryArc

Reputation: 4837

Seems that behavior you have described is caused by layout_gravity attribute of your NestedScrollView. Try to remove it.

Upvotes: 2

Related Questions