Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NestedScrollView and CoordinatorLayout. Issue on Scrolling

I have a strange issue with the CoordinatorLayout and the NestedScrollView (with the design support library 22.2.0)

Using a content smaller than NestedScrollView I should have a fixed content. However trying to scroll up and down the content I can obtain that the content is displaced and never again in their own place.

Here a little sample:enter image description here

Here the code:

<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/main_content"     android:layout_width="match_parent"     android:layout_height="match_parent">      <android.support.design.widget.AppBarLayout         android:id="@+id/appbar"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">              <android.support.v7.widget.Toolbar                 android:id="@+id/toolbar"                 android:layout_width="match_parent"                 android:layout_height="?attr/actionBarSize"                 android:background="?attr/colorPrimary"                 app:popupTheme="@style/ThemeOverlay.AppCompat.Light"                 app:layout_scrollFlags="scroll|enterAlways" />      </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">          <FrameLayout             android:paddingTop="24dp"             android:id="@+id/fragment_container"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:padding="@dimen/padding">          </FrameLayout>      </android.support.v4.widget.NestedScrollView>      <android.support.design.widget.FloatingActionButton         android:id="@+id/fab_action"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="end|bottom"         android:layout_margin="16dp"         android:visibility="gone"         android:src="@drawable/ic_done" />  </android.support.design.widget.CoordinatorLayout> 
like image 582
Gabriele Mariotti Avatar asked Jun 12 '15 14:06

Gabriele Mariotti


People also ask

How do I stop NestedScrollView scrolling?

setnestedscrollingenabled set it to false.

What is the difference between NestedScrollView and ScrollView?

NestedScrollView is just like ScrollView , but it supports acting as both a nested scrolling parent and child on both new and old versions of Android. Nested scrolling is enabled by default.


1 Answers

I think that it is not a bug in the support lib,just use this

<android.support.v4.widget.NestedScrollView     xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:fillViewport="true"     android:layout_gravity="fill_vertical"     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 
like image 62
LiFei Avatar answered Sep 18 '22 15:09

LiFei