使用 AppCompat v21 时何时将工具栏设置为操作栏?

When to set a Tool Bar as an Action Bar when using AppCompat v21?

Google 在 AppCompat v21 中引入了工具栏小部件。我知道您可以在 Activity 中将工具栏指定为操作栏(通过 setSupportActionBar())。

将工具栏安装为操作栏而不是一直在布局中使用独立的工具栏有什么好处?工具栏在作为操作栏安装时可以执行的操作是否有独立使用时无法执行的操作?

linked article稍微涉及到这个话题:"Use a Toolbar as an Action Bar when you want to use the existing Action Bar facilities (such as menu inflation and selection, ActionBarDrawerToggle, and so on) but want to have more control over its appearance."

...但他们使用了包罗万象的 "and so on"。 Action Bar 还提供了哪些其他功能,而人们错过了独立工具栏?

使用工具栏作为 UI 组件的一部分的主要优点是您可以向其添加动画....例如,我认为您之前可能使用过 Play 商店,因为当您打开一个应用程序,您可以在滚动时看到该应用程序的视频或应用程序显示的屏幕截图,您可以看到不知从哪里出现的 ActionBar……如果您在您的应用程序中使用 ActionBar,则无法实现这些类型的动画。 .. 使用工具栏的另一个实例是您可以在需要时隐藏它...滚动列表视图时您可以隐藏它,这样您就可以为您的内容提供更多空间...这不能用 ActionBar 完成。 ..

我认为总结了ToolBar优于ActionBar的本质

编辑 1: 抱歉 Google 更改了它的 Play 商店 UI 所以你找不到那个所以我建议你查看一个名为 Zomato

的应用程序