gpt4 book ai didi

Android Lollipop 工具栏与自定义 View

转载 作者:IT老高 更新时间:2023-10-28 23:18:34 25 4
gpt4 key购买 nike

我刚刚了解了 Android Lollipop 中的新工具栏。它继承自 ViewGroup。

为什么使用新工具栏比使用线性布局更有优势发表自己的看法?

最佳答案

解释:

您应该开始使用 ToolBar 而不是 ActionBar。这直接取自 Android 开发者文档。它比普通的 ActionBar 具有更大的灵 active ;但是,保留了一些更突出的功能,例如添加Logo、支持“向上”导航膨胀菜单actionviews strong> 例如 SearchView。

教程:

Implement yourself(by Chris Banes)

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

文档:

Normal Toolbar(API 21+)

AppCompat Support v7 Toolbar(API 7+)

A standard toolbar for use within application content.

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.

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.

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.

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 Lollipop 工具栏与自定义 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26508934/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com