返回介绍

NavigationBar

发布于 2020-10-20 06:58:13 字数 3796 浏览 1088 评论 0 收藏 0

Extends Widget

The navigation bar is the onscreen area where Back, Home and similar buttons are displayed. The singleton instance can be accessed via ui.navigationBar and is only supported on Android.

Import this type with “const {NavigationBar} = require('tabris');

Properties

background

Android

Type: Color

Background color of the navigation bar.

displayMode

Android

Type: string, supported values: default, hide, float, default: default

Controls how the navigation bar is positioned relative to the ui.contentView. The value default places the content above the navigation bar. The hide option lets the navigation bar disappear, making room for the content. The float option lets the content flow underneath the navigation bar.

height

Android

read-only
Type: number

The height of the navigation bar in device independent pixel. Can be used in conjunction with the displayMode float to offset the content as to not have it covered by the navigation bar.
This property can only be set on widget creation. Once set, it cannot be changed anymore.

Events

backgroundChanged

Fired when the background property has changed.

Event Parameters

  • target: this The widget the event was fired on.

  • value: Color The new value of background.

displayModeChanged

Fired when the displayMode property has changed.

Event Parameters

  • target: this The widget the event was fired on.

  • value: string The new value of displayMode.

Example

const {Picker, TextView, ui} = require('tabris');

const DISPLAY_MODES = ['default', 'float', 'hide'];
const BACKGROUNDS = [ui.navigationBar.background, 'rgba(0, 0, 0, 0.25)', 'red', 'green', 'blue'];

createTextView('Display mode', 'displayMode');

new Picker({
  left: '#displayMode 16', baseline: 'prev()', right: 16,
  itemCount: DISPLAY_MODES.length,
  itemText: index => DISPLAY_MODES[index]
}).on('select', ({index}) => ui.navigationBar.displayMode = DISPLAY_MODES[index])
  .appendTo(ui.contentView);

createTextView('Background');

new Picker({
  left: '#displayMode 16', baseline: 'prev()', right: 16,
  itemCount: BACKGROUNDS.length,
  itemText: index => BACKGROUNDS[index]
}).on('select', ({index}) => ui.navigationBar.background = BACKGROUNDS[index])
  .appendTo(ui.contentView);

createTextView('Height');

new TextView({
  left: '#displayMode 16', baseline: 'prev()', right: 16,
  text: ui.navigationBar.height
}).appendTo(ui.contentView);

function createTextView(text, id) {
  new TextView({
    id: id,
    left: 16, top: 'prev() 16',
    text: text
  }).appendTo(ui.contentView);
}

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文