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

2023-09-12 03:05:38 作者:哇!许仙敢曰蛇

我想通过以下方式定制我的抽屉式导航栏:

而不是当前默认的动画稍微滑动菜单图标的左边我想有一个图标显示在抽屉是打开的,另一个当抽屉被关闭。

任何想法/通向哪里能找到这样的事情?

我已经做了一些研究,才得以有机会操作栏中的图标,但是,不幸的是,这不是我所期待的。

难道说这是不是可能?

我猜的变化应该发生在这里:

  mDrawerToggle =新ActionBarDrawerToggle(
                getActivity()/ *主机活动* /
                mDrawerLayout,/ * DrawerLayout对象* /
                R.drawable.ic_drawer,/ *导航抽屉图像,以取代上插入符* /
                R.string.navigation_drawer_open,/ *开放抽屉说明访问* /
                R.string.navigation_drawer_close / *关闭抽屉说明访问* /
        )
 

解决方案

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

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

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

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

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

安卓apex启动器抽屉里面的图标怎么改啊

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.