使用jetpack导航,单个Activity具有多个片段。通过导航图中定义的操作从主片段导航到另一个片段后,汉堡菜单图标保持不变,它没有更改为后退箭头按钮。
如何将这个汉堡菜单图标更改为后退箭头按钮?当单击时,它应该返回到主片段。
在Android Studio中创建一个新项目,并选择Navigation Drawer Activity作为模板,将使用上述3个片段设置单个Activity。
使用jetpack导航,单个Activity具有多个片段。通过导航图中定义的操作从主片段导航到另一个片段后,汉堡菜单图标保持不变,它没有更改为后退箭头按钮。
如何将这个汉堡菜单图标更改为后退箭头按钮?当单击时,它应该返回到主片段。
在Android Studio中创建一个新项目,并选择Navigation Drawer Activity作为模板,将使用上述3个片段设置单个Activity。
3条答案
按热度按时间w3nuxt5m1#
只需将此添加到根Activity中。
uubf1zoe2#
在您的活动中尝试此操作
ikfrs5lh3#
我在AppBarConfiguration中设置了多个片段。
由于详细信息片段是在AppBarConfiguration中设置的,因此当从主片段导航到详细信息片段时,汉堡菜单图标保持不变,因为详细信息片段被设置为drawerlayout之一。
从AppBarConfiguration中删除R.id.nav_detail后,导航到detail片段,汉堡菜单图标将自动更改为带有DrawerArrowDrawable动画的后退箭头图标。