NavigationBar

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

  1. const {Picker, TextView, ui} = require('tabris');
  2. const DISPLAY_MODES = ['default', 'float', 'hide'];
  3. const BACKGROUNDS = [ui.navigationBar.background, 'rgba(0, 0, 0, 0.25)', 'red', 'green', 'blue'];
  4. createTextView('Display mode', 'displayMode');
  5. new Picker({
  6. left: '#displayMode 16', baseline: 'prev()', right: 16,
  7. itemCount: DISPLAY_MODES.length,
  8. itemText: index => DISPLAY_MODES[index]
  9. }).on('select', ({index}) => ui.navigationBar.displayMode = DISPLAY_MODES[index])
  10. .appendTo(ui.contentView);
  11. createTextView('Background');
  12. new Picker({
  13. left: '#displayMode 16', baseline: 'prev()', right: 16,
  14. itemCount: BACKGROUNDS.length,
  15. itemText: index => BACKGROUNDS[index]
  16. }).on('select', ({index}) => ui.navigationBar.background = BACKGROUNDS[index])
  17. .appendTo(ui.contentView);
  18. createTextView('Height');
  19. new TextView({
  20. left: '#displayMode 16', baseline: 'prev()', right: 16,
  21. text: ui.navigationBar.height
  22. }).appendTo(ui.contentView);
  23. function createTextView(text, id) {
  24. new TextView({
  25. id: id,
  26. left: 16, top: 'prev() 16',
  27. text: text
  28. }).appendTo(ui.contentView);
  29. }

See also

原文:

https://youjingyu.github.io/Tabris-Documention/?folderName=widgets&pageName=NavigationBar.html