title: mimicking the navigation drawer of youtube/gmail app
body: <h2>Background</h2>
  
  <p>In the recent months Google released the <a href="http://www.androidpolice.com/2013/08/19/breaking-massive-youtube-for-android-v5-0-update-brings-brand-new-ui-in-app-multitasking-and-much-more/" rel="nofollow noreferrer">Youtube app</a> with navigation drawer (AKA sliding menu).</p>
  
  <p>it has many cool features that i wish to have on an app i'm working on.</p>
  
  <p>the features are:</p>
  
  <ol>
  <li><p>touch anywhere to start sliding. </p></li>
  <li><p>moving icon on the "up" button of the action bar when switching modes.</p></li>
  <li><p>content area (the area on the right, not the menu itself) stays instead of scrolling, when sliding the menu.</p></li>
  <li><p>action bar stays instead of scrolling.</p></li>
  <li><p>content area (the area on the right, not the menu itself) changes its color when scrolling, and not the menu itself.</p></li>
  </ol>
  
  <p>here are screenshots to show what i'm talking about :</p>
  
  <p>before sliding: </p>
  
  <p><img src="https://i.stack.imgur.com/8vQ5e.png" alt="before"></p>
  
  <p>after sliding:</p>
  
  <p><img src="https://i.stack.imgur.com/YhzoN.png" alt="after"></p>
  
  <p>currently, i know of 2 main libraries that are responsible of using a navigation drawer :</p>
  
  <ul>
  <li><p>the official <a href="http://developer.android.com/training/implementing-navigation/nav-drawer.html" rel="nofollow noreferrer">google navigation drawer library</a> .</p></li>
  <li><p>the <a href="https://github.com/jfeinstein10/SlidingMenu" rel="nofollow noreferrer">sliding menu library, by jfeinstein10</a> .</p></li>
  </ul>
  
  <h2>the problem</h2>
  
  <p>both the official library and the slidingMenu library don't have all of those features combined like on the youtube app. </p>
  
  <p>for example, the official library doesn't have ability #1 (that's why i've posted <a href="https://stackoverflow.com/questions/17699869/how-to-show-the-drawerlayout-when-sliding-from-left-to-right-no-matter-where">this thread</a>) , so i used the slidingMenu library instead.</p>
  
  <p>however, the slidingMenu library doesn't have (or is it?) ability #2 and #3 . </p>
  
  <p>both libraries don't have enough documentation/examples of what can be done, so it's very hard to use them or add new features to them.</p>
  
  <h2>what i've tried</h2>
  
  <p>currently, i use the slidingMenu library, so this is my code for preparing the slidingMenu :</p>
  
  <pre><code>activity.setBehindContentView(slidingMenuRootView);
  mSlidingMenu = activity.getSlidingMenu();
  mSlidingMenu.setShadowWidthRes(R.dimen.slidingmenu_shadow_width);
  mSlidingMenu.setShadowDrawable(R.drawable.slidingmenu_shadow);
  mSlidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
  mSlidingMenu.setFadeEnabled(true);
  mSlidingMenu.setFadeDegree(1.0f);
  mSlidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
  activity.setSlidingActionBarEnabled(false);
  </code></pre>
  
  <h2>question</h2>
  
  <p>how can i get the slidingMenu (or navigation drawer) to act like on youtube app , meaning with all of the features i've mentioned combined ?</p>
  
  <hr>
  
  <h2>possible solution</h2>
  
  <p>EDIT: using the <a href="http://simonvt.github.io/android-menudrawer/" rel="nofollow noreferrer">menuDrawer library</a> (github link <a href="https://github.com/SimonVT/android-menudrawer" rel="nofollow noreferrer">here</a>) , i've successfully achieved all of the features i've mentioned. here's a sample code:</p>
  
  <pre><code>public class ActionBarSherlockSample extends SherlockActivity {
  
      private MenuDrawer mDrawer;
  
      @Override
      protected void onCreate(final Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          getSupportActionBar();
          mDrawer = MenuDrawer.attach(this, MenuDrawer.Type.OVERLAY);
          final TextView menuView = new TextView(this);
          menuView.setTextColor(0xFFFFFFFF);
          menuView.setText("As the drawer opens, the drawer indicator icon becomes smaller.");
          menuView.setGravity(Gravity.CENTER);
          mDrawer.setMenuView(menuView);
          mDrawer.setTouchMode(MenuDrawer.TOUCH_MODE_FULLSCREEN);
          mDrawer.setOnDrawerStateChangeListener(new OnDrawerStateChangeListener() {
  
              @Override
              public void onDrawerStateChange(final int oldState, final int newState) {
                  Log.d("AppLog", "oldState:" + oldState + " newState:" + newState);
              }
  
              @Override
              public void onDrawerSlide(final float openRatio, final int offsetPixels) {
              }
          });
          final TextView contentView = new TextView(this);
          contentView
                  .setText("This sample uses ActionBarSherlock to display an ActionBar on older platforms. The drawer indicator, "
                          + "as per the design guidelines, is visible in the top left corner.");
          contentView.setGravity(Gravity.CENTER);
          mDrawer.setContentView(contentView);
          mDrawer.setSlideDrawable(R.drawable.ic_drawer);
          mDrawer.setDrawerIndicatorEnabled(true);
      }
  
      @Override
      public boolean onOptionsItemSelected(final MenuItem item) {
          switch (item.getItemId()) {
          case android.R.id.home:
              mDrawer.toggleMenu();
              break;
          }
          return super.onOptionsItemSelected(item);
      }
  }
  </code></pre>