在Android的抽屉抽屉式导航自定义图标打开/关闭 [英] Android Navigation Drawer custom Icons on drawer opened/closed
问题描述
我想通过以下方式定制我的抽屉式导航栏:
而不是当前默认的动画稍微滑动菜单图标的左边我想有一个图标显示在抽屉是打开的,另一个当抽屉被关闭。
任何想法/通向哪里能找到这样的事情?
我已经做了一些研究,才得以有机会操作栏中的图标,但是,不幸的是,这不是我所期待的。
难道说这是不是可能?
我猜的变化应该发生在这里:
mDrawerToggle =新ActionBarDrawerToggle(
getActivity()/ *主机活动* /
mDrawerLayout,/ * DrawerLayout对象* /
R.drawable.ic_drawer,/ *导航抽屉图像,以取代上插入符* /
R.string.navigation_drawer_open,/ *开放抽屉说明访问* /
R.string.navigation_drawer_close / *关闭抽屉说明访问* /
)
基于我的阅读<一个href="https://android.googlesource.com/platform/frameworks/support/+/refs/heads/master/v4/java/android/support/v4/app/ActionBarDrawerToggle.java"相对=nofollow>的 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 aLevelListDrawable
or something to represent the two states, andModify
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.
这篇关于在Android的抽屉抽屉式导航自定义图标打开/关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!