title: onOffsetChanged method from OnOffsetChangedListener of AppBarLayout being constantly called
body: <p>I have been looking for an answer to this for days. There's not a single thing online I can use.</p>
  
  <p>My problem is that when adding an OnOffsetChangedListener to the AppBarLayout, its method (onOffsetChaned) gets called over and over again, even if I'm not touching the screen. Aditionally, the values of verticalOffset never change, nor does the getHeight() value returned by the Toolbar or the AbbBarLayout.</p>
  
  <p>I think it's important to add that this happens also using a master detail flow template from Android Studio without changing anything other than adding the code to the activity, so I don't think it's something in my code.</p>
  
  <p>Thanks in advance.</p>
  
  <p><strong>This is the code I'm using</strong></p>
  
  <pre><code>appbarLayout = (AppBarLayout) findViewById(R.id.app_bar);
      appbarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
          @Override
          public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
              showToast(String.valueOf(appBarLayout.getHeight()));
              if (Math.abs(verticalOffset) == appBarLayout.getTotalScrollRange()) {
                  showToast("Collapsed");
              } else if (verticalOffset == 0) {
                  showToast("Expanded");
              } else {
                 showToast("Scrolling");
              }
          }
      });
  </code></pre>
  
  <p><strong>And this is my XML file</strong> </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true"
      tools:context=".views.ActivityTaskList"
      tools:ignore="MergeRootFrame"&gt;
  
      &lt;android.support.design.widget.AppBarLayout
          android:id="@+id/app_bar"
          android:layout_width="match_parent"
          android:layout_height="170dp"
          android:fitsSystemWindows="true"
          android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"&gt;
  
          &lt;android.support.design.widget.CollapsingToolbarLayout
              android:id="@+id/toolbar_layout"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:fitsSystemWindows="true"
              app:contentScrim="?attr/colorPrimary"
              app:expandedTitleGravity="start|top"
              app:expandedTitleMarginTop="16dp"
              app:expandedTitleMarginStart="20dp"
              app:expandedTitleTextAppearance="@style/TextAppearance.AppCompat.Title"
              app:layout_scrollFlags="scroll|exitUntilCollapsed"
  
              app:toolbarId="@+id/toolbar"&gt;
  
              &lt;android.support.constraint.ConstraintLayout
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"&gt;
  
                  &lt;EditText
                      android:id="@+id/input_layout_task"
                      style="@style/Widget.AppCompat.EditText"
                      android:layout_width="0dp"
                      android:layout_height="wrap_content"
                      android:layout_marginEnd="8dp"
                      android:layout_marginStart="72dp"
                      android:layout_marginTop="48dp"
                      android:hint="I need to..."
                      android:textAppearance="@style/TextAppearance.AppCompat"
                      android:theme="@style/ToolbarEditText"
                      app:layout_constraintHorizontal_bias="0.0"
                      app:layout_constraintLeft_toLeftOf="parent"
                      app:layout_constraintRight_toRightOf="parent"
                      app:layout_constraintTop_toTopOf="parent" /&gt;
  
  
                  &lt;TextView
                      android:id="@+id/tvDatePicker"
                      style="@style/Base.Widget.AppCompat.Spinner"
                      android:layout_width="0dp"
                      android:layout_height="wrap_content"
                      android:layout_alignParentTop="true"
                      android:layout_marginStart="4dp"
                      android:layout_marginTop="0dp"
                      android:paddingTop="16dp"
                      android:text="Fecha"
                      app:layout_constraintHorizontal_bias="0.1"
                      app:layout_constraintLeft_toLeftOf="@+id/input_layout_task"
                      app:layout_constraintRight_toRightOf="parent"
                      app:layout_constraintTop_toBottomOf="@+id/input_layout_task" /&gt;
  
                  &lt;ImageView
                      android:id="@+id/imageView2"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:layout_marginBottom="0dp"
                      android:layout_marginLeft="16dp"
                      android:layout_marginTop="0dp"
                      app:layout_constraintBottom_toTopOf="@+id/tvDatePicker"
                      app:layout_constraintLeft_toLeftOf="parent"
                      app:layout_constraintTop_toTopOf="@+id/input_layout_task"
                      app:layout_constraintVertical_bias="0.44"
                      app:srcCompat="@drawable/ic_label_black_24dp" /&gt;
  
                  &lt;ImageView
                      android:id="@+id/imageView3"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:layout_marginBottom="0dp"
                      android:layout_marginEnd="32dp"
                      android:layout_marginStart="14dp"
                      android:layout_marginTop="8dp"
                      app:layout_constraintBottom_toBottomOf="@+id/tvDatePicker"
                      app:layout_constraintLeft_toLeftOf="parent"
                      app:layout_constraintRight_toLeftOf="@+id/tvDatePicker"
                      app:layout_constraintTop_toTopOf="@+id/tvDatePicker"
                      app:layout_constraintVertical_bias="1.0"
                      app:srcCompat="@drawable/ic_date_range_black_24dp" /&gt;
  
  
              &lt;/android.support.constraint.ConstraintLayout&gt;
  
              &lt;android.support.v7.widget.Toolbar
                  android:id="@+id/detail_toolbar"
                  android:layout_width="match_parent"
                  android:layout_height="?attr/actionBarSize"
                  app:layout_collapseMode="pin"
                  app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /&gt;
  
          &lt;/android.support.design.widget.CollapsingToolbarLayout&gt;
  
  
      &lt;/android.support.design.widget.AppBarLayout&gt;
  
      &lt;FrameLayout
          android:id="@+id/frameLayout"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          app:layout_behavior="@string/appbar_scrolling_view_behavior"&gt;
  
          &lt;include layout="@layout/task_list" /&gt;
      &lt;/FrameLayout&gt;
  
      &lt;android.support.design.widget.FloatingActionButton
          android:id="@+id/fab"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="bottom|end"
          android:layout_margin="@dimen/fab_margin"
          android:src="@drawable/ic_add_black_24dp"
          android:tint="@android:color/white"
          app:fabSize="normal" /&gt;
  
  
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>