Mate
Mate

Reputation: 301

Kivy: show action bar on all screens

I would like to show an 'action bar' on all screens, without copying and pasting the code to all the screens.

My question is if it possible or not?

here is the kv file:

Manager:
    Screen_one:
    Screen_two:
    Screen_three:

<Screen_one>:
    GridLayout:
        rows: 2
        size: root.size

        ActionBar:
            background_color: 0, .4, .7, 1
            size_hint_y: None
            height: '35dp'
            ActionView:
                use_separator: True
                ActionPrevious:
                    title: 'Menu:'
                    with_previous: False
                ActionOverflow:
                ActionButton:
                    important: True
                    text: 'Print'

Upvotes: 2

Views: 389

Answers (1)

ikolim
ikolim

Reputation: 16011

Yes, it is possible.

  1. Declare a root with inheritance of a BoxLayout widget
  2. Instantiate ActionBar and ScreenManager widgets as children of root

Snippets

BoxLayout:
    orientation: 'vertical'
    ActionBar:
        ...
    ScreenManager:
        id: sm
        Screen_one:
        Screen_two:
        Screen_three:

<Screen_one>:
    ...

    

Upvotes: 3

Related Questions