目前,我正在将 Holo 设计的应用程序迁移到 Material 设计的应用程序。
我发现了以下文章:http://android-developers.blogspot.com/2014/10/appcompat-v21-material-design-for-pre.html
In this release, Android introduces a new Toolbar widget. This is a generalization of the Action Bar pattern that gives you much more control and flexibility. Toolbar is a view in your hierarchy just like any other, making it easier to interleave with the rest of your views, animate it, and react to scroll events. You can also set it as your Activity’s action bar, meaning that your standard options menu actions will be display within it.
上面的文字对我来说似乎不太清楚。我的第一印象是这样的。
Toolbar
比ActionBar
更强大。它可以完成ActionBar
可以做的所有事情,还提供一些其他额外的功能。- Google 似乎希望推广
Toolbar
而不是ActionBar
我想知道,我们如何决定,什么时候应该使用 ActionBar
,什么时候应该使用 Toolbar
。
我想要实现的目标是类似于最新的 Google Play 商店应用。
抽屉导航位于操作栏下方
有collapseActionView
我可以将我的菜单指定为
<item
android:id="@+id/menu_search"
android:title="@string/menu_search"
android:showAsAction="always|collapseActionView"
android:actionLayout="@layout/collapsible_searchtext"
android:icon="?attr/actionBarSearchIcon"/>
我发现了最新的 Google Play 报亭
抽屉导航覆盖操作栏
- 如果我想要操作栏上的抽屉导航盖功能,
工具栏
是必须的吗? - 如果我只想拥有抽屉导航位于操作栏下方和有collapseActionView功能,将
ActionBar
足够了吗?
最佳答案
ActionBars是工具栏(刚刚为您创建并添加到 contentView 中),因此区别有点无关紧要。
提醒一下,操作栏上方的抽屉导航是根据 Material Design checklist 的 Material 设计指南并且应该是您使用的唯一模型(official Android App Design Google+ community 上已经进行了很多讨论,它已经证实了这一事实,并且所有 Google 应用程序都正在转向该标准)。
关于android - 迁移到 Material 设计 - 我们应该使用工具栏还是操作栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26696385/