سؤال

I would like to customize my navigation drawer in the following manner:

instead of the current default animation that slides the menu icon slightly to the left i would like to have one icon displayed when the drawer is open and another when the drawer is closed.

Any ideas/leads onto where i could find anything like that?

I have done some research, was able to chance the action bar icon but that unfortunately this is not what i am looking for.

Could it be that this is not even possible?

I am guessing changes should take place around here:

mDrawerToggle = new ActionBarDrawerToggle(
                getActivity(),                    /* host Activity */
                mDrawerLayout,                    /* DrawerLayout object */
                R.drawable.ic_drawer,             /* nav drawer image to replace 'Up' caret */
                R.string.navigation_drawer_open,  /* "open drawer" description for accessibility */
                R.string.navigation_drawer_close  /* "close drawer" description for accessibility */
        )
هل كانت مفيدة؟

المحلول

Based upon my reading of the ActionBarDrawerToggle source, you would need to fork the implementation of ActionBarDrawerToggle and modify it to:

  • Either hold two Drawable resource IDs or use a LevelListDrawable or something to represent the two states, and

  • Modify setActionBarUpIndicator() to take the change listed above into account

Note that users are only now starting to come to grips with the "mini hamburger" indicator meaning that there is a navigation drawer. Switching away from that convention may harm, not improve, your app's usability.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top