1

i'm using the sliding menu by jfeinstein10, i'm able to set the navigation drawer icon given here

http://romannurik.github.io/AndroidAssetStudio/icons-nav-drawer-indicator.html.

Now i want to know how to set the animation for it, i.e like when i drag the sliding list it should show the small moment effect like how we see in play store app.

I'm using ABS library for actionbar

Naruto
  • 9,476
  • 37
  • 118
  • 201

1 Answers1

0

For app icon control for nav drawer, add new property on MainActivity

ActionBarDrawerToggle mDrawerToggle;

add open and close description in values/string/

<string name="drawer_open">Open navigation drawer</string>
<string name="drawer_close">Close navigation drawer</string>

Add the app icon control code inside MainActivity oncreate

mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerToggle = new ActionBarDrawerToggle(
    this,
    mDrawerLayout,
    R.drawable.ic_drawer, 
    R.string.drawer_open, 
    R.string.drawer_close 
    ) {

/** Called when a drawer has settled in a completely closed state. */
public void onDrawerClosed(View view) {
    super.onDrawerClosed(view);
    getActionBar().setTitle(mTitle);
}

/** Called when a drawer has settled in a completely open state. */
public void onDrawerOpened(View drawerView) {
    super.onDrawerOpened(drawerView);
    getActionBar().setTitle(mDrawerTitle);
}
};

mDrawerLayout.setDrawerListener(mDrawerToggle);

getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);

Add onOptionsItemSelected() method. This is really needed to make app icon a toggle of nav drawer.

@Override
public boolean onOptionsItemSelected(MenuItem item) {

if (mDrawerToggle.onOptionsItemSelected(item)) {
   return true;
}

return super.onOptionsItemSelected(item);
}

And finally, in onPostCreate() method. This is really needed to change the up caret icon before the app icon

@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
mDrawerToggle.syncState();
}
Farouk Touzi
  • 3,451
  • 2
  • 19
  • 25