title: Prevent CollapsingToolBarLayout from expanding programmatically
body: <p>I'm using a CollapsingToolBarLayout in my main activity, but only want it to be expandable in some fragments. To do this, I've been using these methods(right after fragment transactions/detatch). These successfully animate the toolbar, but it is still expandable in fragments that have called lockAppBarClosed.</p>
  
  <pre><code>public void unlockAppBarOpen(boolean animate){
      appBarLayout.setExpanded(true, animate);
      appBarLayout.setEnabled(true);
      appBarLayout.setActivated(true);
  }
  public void lockAppBarClosed(boolean animate){
      appBarLayout.setExpanded(false, animate);
      appBarLayout.setEnabled(false);
      appBarLayout.setActivated(false);
  }
  </code></pre>
  
  <p><code>setEnabled</code> and <code>setActivated</code> seem to do nothing.</p>
  
  <p>For reference, here is my app_bar_main.xml file:</p>
  
  <p></p>
  
  <pre><code>&lt;android.support.design.widget.AppBarLayout
      android:id="@+id/appbar"
      android:layout_width="match_parent"
      android:layout_height="@dimen/app_bar_extended"
      android:fitsSystemWindows="true"
      android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"&gt;
      &lt;android.support.design.widget.CollapsingToolbarLayout
          android:id="@+id/collapsing_toolbar"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:fitsSystemWindows="true"
          app:contentScrim="?attr/colorPrimary"
          app:expandedTitleTextAppearance="@android:color/transparent"
          app:layout_scrollFlags="scroll|exitUntilCollapsed"&gt;
          &lt;android.support.v7.widget.Toolbar
              android:id="@+id/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/fragment_container"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:focusable="true"
      android:clickable="true"
      android:background="?android:attr/selectableItemBackground"
      app:layout_behavior="@string/appbar_scrolling_view_behavior"&gt;
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>I've tried setting the height of the AppBarLayout via LayoutParams(), but this, for some reason, prevents the animation from playing, even when <code>animate</code> is set to true. Setting the scroll flags to none or <code>always collapsed</code> does nothing, and I'm not looking for the scroll <code>snap</code> effect either.</p>
  
  <p>Ideally, there should be no animation of the appbar in one fragment(just like normal), and collapsing/expanding animations when going between fragments and in desired ones.</p>
  
  <p>If you have any suggestions, they would be highly appreciated.
  Thank you.</p>