简体   繁体   English

使用导航组件折叠工具栏

[英]Collapsing toolbar using navigation components

I'm creating an application that uses the Jetpack navigation Components with multiple fragments and single activity.我正在创建一个应用程序,该应用程序使用具有多个片段和单个活动的Jetpack navigation Components

The activity contains the FragmentContainerView in addition to the AppBar which includes only a Toolbar that is supposed to be shared between all fragments.除了AppBar之外,该活动还包含 FragmentContainerView,AppBar 仅包含一个应该在所有片段之间共享的Toolbar

Now what I'm trying to do is to use a Collapsing Toolbar in one of these fragments with an Image to view some details, and make a shared element transition to it.现在我要做的是在这些片段之一中使用Collapsing Toolbar和图像来查看一些细节,并使共享元素过渡到它。

Is it possible to implement that?有可能实现吗?

In the themes, set the theme as NoActionBar在主题中,将主题设置为 NoActionBar

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <!-- changed .DarkActionBar to .NoActionBar -->
   <!-- Customize your theme here. -->
   <item name="colorPrimary">@color/colorPrimary</item>
   <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
   <item name="colorAccent">@color/colorAccent</item>
</style>

Then add a toolbar in each fragment.然后在每个片段中添加一个工具栏。

You can have a Toolbar or a CollapsingToolbar depending on your need.您可以根据需要使用 Toolbar 或 CollapsingToolbar。

Follow the links to check on implementing the Collapsing toolbar按照链接检查是否实施折叠工具栏

Expanding And Collapsing Toolbar In Android 展开和折叠工具栏 Android

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM