title: Android Toolbar how to save state?
body: <p>What is the correct way of saving android.support.v7.widget.Toolbar state?</p>
  
  <p>I was expecting it should be saved out of the box. Ids are set in xml, but still does not work.</p>
  
  <p>I have tried things bellow, but it does not work.</p>
  
  <p>Do I have to save everything manually by getter and setters? Or do I miss something?</p>
  
  <p>It seems to be bug.</p>
  
  <p>In Activity:</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      initializeInjector();
      setContentView(R.layout.activity_main);
      ButterKnife.bind(this);
  
  
      if (savedInstanceState != null) {
          tabFragment = (TabFragment) getSupportFragmentManager().findFragmentByTag(TAB_FRAGMENT_TAG);
      } else {
          tabFragment = getTabFragmentInstance();
          getSupportFragmentManager().beginTransaction().add(R.id.containerView,tabFragment , TAB_FRAGMENT_TAG).commit();
      }
  
  }
  
  @Override
  protected void onSaveInstanceState(Bundle outState) {
      super.onSaveInstanceState(outState);
      ParcelableSparseArray toolbarState = new ParcelableSparseArray();
      toolbar.setSaveEnabled(true);
      toolbar.setSaveFromParentEnabled(true);
      toolbar.saveHierarchyState(toolbarState);
      outState.putSparseParcelableArray(TOOLBAR_STATE,toolbarState);
  
  }
  
  @Override
  protected void onRestoreInstanceState(Bundle savedInstanceState) {
      super.onRestoreInstanceState(savedInstanceState);
      SparseArray&lt;Parcelable&gt; toolbarState = savedInstanceState.getSparseParcelableArray(TOOLBAR_STATE);
      toolbar.restoreHierarchyState(toolbarState);
  }
  </code></pre>
  
  <p>layout file:</p>
  
  <pre><code>&lt;android.support.v4.widget.DrawerLayout
  android:id="@+id/drawerLayout"
  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:openDrawer="start"
  &gt;
  
  &lt;android.support.design.widget.CoordinatorLayout
      android:id="@+id/activity_main_Layout_parent"
      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:orientation="vertical"
      &gt;
  
      &lt;FrameLayout
          android:id="@+id/containerView"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical"
          app:layout_behavior="@string/appbar_scrolling_view_behavior"&gt;
      &lt;/FrameLayout&gt;
  
  
      &lt;android.support.design.widget.AppBarLayout
          android:id="@+id/app_bar_layout"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          app:layout_behavior="@string/appbar_scrolling_view_behavior"&gt;
  
          &lt;android.support.v7.widget.Toolbar
              android:id="@+id/toolbar"
              android:saveEnabled="true"
              app:layout_scrollFlags="enterAlways"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:background="@color/colorPrimary"
              android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
              app:layout_behavior="@string/appbar_scrolling_view_behavior"
  
              /&gt;
  
  
      &lt;/android.support.design.widget.AppBarLayout&gt;
  
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  
  &lt;android.support.design.widget.NavigationView
      android:id="@+id/navigationView"
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:layout_gravity="start"
      app:itemTextColor="@color/black"
      app:menu="@menu/drawer_menu"
      /&gt;
  </code></pre>
  
  <p></p>
  
  <p>Thx</p>
  
  <p>Edit01: I am setting Toolbar's properties ie. Visibility, Title and Menu . After rotation these seems to be inflated from .xml. Toolbar is setup by fragments and is injected from activity.  </p>