且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Android的抽屉抽屉式导航自定义图标打开/关闭

更新时间:2022-12-11 15:25:05

基于我的阅读的 ActionBarDrawerToggle 源,你需要到餐桌 ActionBarDrawerToggle 的执行>和修改为:

  • 无论是持有两个绘制对象资源ID或使用 LevelListDrawable 或东西重新present两种状态,以及

  • 修改 setActionBarUpIndicator()采取上述考虑改变

请注意,用户现在才开始着手解决小汉堡的指标含义,有一个抽屉式导航。从该公约的交换走可能会伤害,不能提高,你的应用程序的可用性。

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.