在导航视图中仅折叠一个片段的工具栏 [英] Collapsing Toolbar only for one Fragment in Navigation View

查看:62
本文介绍了在导航视图中仅折叠一个片段的工具栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有不同片段的导航抽屉.每个Fragment应该使用一个默认工具栏,除了一个Fragment需要折叠的Toolbar.

I have a navigation drawer with different fragments. There is a default toolbar every Fragment should use, except of one Fragment which needs a collapsing Toolbar.

如何在片段的工具栏之间切换?

How can I switch between the toolbars for the fragments ?

推荐答案

似乎您想要实现这样的目标.

It seems you want to achieve something like this.

我使用通用工具栏进行了活动.当切换到折叠的工具栏片段时,我已经使工具栏透明,并且片段的工具栏接管了.切换到其他片段时,工具栏的颜色保持不变.

I have made an activity with common toolbar. when switching to the collapsing toolbar fragment I've made the toolbar transparent and fragment's toolbar takes over. The toolbar's color remains the same on switching to other fragments.

这使您可以在xml中管理完整的折叠式工具栏布局结构,而逻辑保留在Fragment中.

This allows you to manage complete collapsing toolbar's layout structure in xml and logic remains in Fragment.

希望这会有所帮助.请参阅链接的gif.

Hope this will help. Refer the gif linked.

Gist for gif

这篇关于在导航视图中仅折叠一个片段的工具栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆