Android的棒棒堂VS工具栏自定义视图 [英] Android Lollipop Toolbar vs Custom view

查看:171
本文介绍了Android的棒棒堂VS工具栏自定义视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚看了一下新的工具栏在Android的棒棒糖。 它继承自ViewGroup中。

I just read about the new Toolbar in Android Lollipop. It inherits from ViewGroup.

为什么使用新的工具栏上,也就是说,一个LinearLayout中的优势 把你自己的看法?

Why are the advantages of using the new Toolbar over, say, a LinearLayout to place your own views?

推荐答案

您应该开始使用工具栏而不是动作条。这是直接从Android开发者文档。它可以比正常的更灵活动作条;然而,保留了一些比较突出的功能,如添加标志,支持向上导航 充气菜单 actionviews 如搜索查看。

Explanation:

You should start using a ToolBar instead of the ActionBar. This is directly taken from the Android Developer documentation. It allows more flexibility than the normal ActionBar; however, retains some the more prominent features such as adding a Logo, supports "up" Navigation, inflating menus and actionviews such as the SearchView.

实现自己(由克里斯·巴内斯)

崩工具栏, FloatingActionButton NavigationView 小吃吧(由克里斯·巴内斯)

Collapsing Toolbar, FloatingActionButton, NavigationView, Snackbar(by Chris Banes)

正常工具栏(API 21 +)

Normal Toolbar(API 21+)

AppCompat支持V7 工具栏 (API 7+)

AppCompat Support v7 Toolbar(API 7+)

一个标准工具栏在应用程序内容中使用。

A standard toolbar for use within application content.

A 工具栏是动作条的范围内使用泛化   应用布局。而一个操作栏是一个传统的一部分   活动的透明窗口的装饰由框架,工具栏控制   可放置在任何嵌套任意水平的图内   层次。应用程序可以选择指定一个工具栏作为   操作栏使用setActionBar()方法的活动。

A Toolbar is a generalization of action bars for use within application layouts. While an action bar is traditionally part of an Activity's opaque window decor controlled by the framework, a Toolbar may be placed at any arbitrary level of nesting within a view hierarchy. An application may choose to designate a Toolbar as the action bar for an Activity using the setActionBar() method.

工具栏支持更集中的特性集相比动作条。从开始   到结束,工具栏可以含有以下任选的组合   内容:

Toolbar supports a more focused feature set than ActionBar. From start to end, a toolbar may contain a combination of the following optional elements:

的导航按钮。这可能是一个向上的箭头,导航菜单切换,   接近,塌陷,完成或应用程序的选择的另一个字形。本   应始终被用来访问其他导航目的地按钮   工具栏和其所指内容或容器内   否则保留当前上下文的工具栏所指。

A navigation button. This may be an Up arrow, navigation menu toggle, close, collapse, done or another glyph of the app's choosing. This button should always be used to access other navigational destinations within the container of the Toolbar and its signified content or otherwise leave the current context signified by the Toolbar.

一个品牌的标志形象。这可以延伸到栏的高度并能   随意宽。

A branded logo image. This may extend to the height of the bar and can be arbitrarily wide.

一个标题和副标题。的标题应该是一个   路标导航工具栏的当前位置   层次结构,并包含有该内容。字幕,如果present   应说明有关当前内容的扩展信息。如果   一个应用程序使用的标志形象,应该认真考虑省略标题   和字幕。

A title and subtitle. The title should be a signpost for the Toolbar's current position in the navigation hierarchy and the content contained there. The subtitle, if present should indicate any extended information about the current content. If an app uses a logo image it should strongly consider omitting a title and subtitle.

一个或多个自定义视图。应用程序可能会增加   任意子视图工具栏。他们将出现在这个   布局中的位置。如果一个子视图的Toolbar.LayoutParams   表明CENTER_HORIZONTAL的重力值的视图将尝试   到后留在工具栏上的可用空间内中心   所有其他元素进行了测量。

One or more custom views. The application may add arbitrary child views to the Toolbar. They will appear at this position within the layout. If a child view's Toolbar.LayoutParams indicates a Gravity value of CENTER_HORIZONTAL the view will attempt to center within the available space remaining in the Toolbar after all other elements have been measured.

的操作菜单。的菜单   行动将针到工具栏的末尾提供了一些常见的,   以及用于可选的溢出菜单中的重要或典型动作   其他操作。在现代的Andr​​oid UI的开发者应该靠更   对工具栏比在视觉上不同的色彩方案的   应用程序图标。利用应用图标加上标题为标准   布局不鼓励对API 21的设备和新的。

An action menu. The menu of actions will pin to the end of the Toolbar offering a few frequent, important or typical actions along with an optional overflow menu for additional actions. In modern Android UIs developers should lean more on a visually distinct color scheme for toolbars than on their application icon. The use of application icon plus title as a standard layout is discouraged on API 21 devices and newer.

这篇关于Android的棒棒堂VS工具栏自定义视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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