Панель инструментов, закрывающая ярлык в кивымде - PullRequest
1 голос
/ 04 мая 2020

Мой MDToolbar покрывает самую верхнюю часть моей метки, я хочу, чтобы текст моей метки отображался под панелью инструментов, также не работает pos_hint, я хочу установить позицию своего текста метки, и я хочу предоставить отступ слева и справа вот мой код в файле .kv

<MainScreen>:
    BoxLayout:
        canvas:
            Color:
                rgb: 0, 0, 0, 0
            Rectangle:
                pos: root.pos
                size: root.size
        ScrollView:
            Label:
                text:
                    """
                    A boy and a girl were playing together. The boy had a collection of marbles. The girl has some
                    sweets with her. The boy told the girl that he would give her all his marbles in exchange for the
                    sweets with her. The girl agreed.

                    The boy kept the most beautiful and the biggest marbles with him and gave her the remaining marbles.
                    The girl gave him all her sweets as she promised. That night the girl slept peacefully. But the boy
                    could not sleep as he kept wondering if the girl has hidden some sweets from him the way he had
                    hidden the best marbles from her.

                    Moral of the Story :

                    If you do not give 100 percent in a relationship, you will always kept doubting if the other person
                    has given her / his hundred percent. This is applicable for any relationship like love, employee –
                    employer, friendship, family, countries, etc…
                    """
                font_size: '20sp'
                height: self.texture_size[1]
                size: self.texture_size
                text_size: root.width, None
                size_hint_x: 1.0
                size_hint_y: None
                halign: "auto"
                valign: "middle"
ScreenManager:
    id: screen_manager

    MainScreen:
        name: 'main'

        NavigationLayout:

            ScreenManager:

                Screen:

                    MDToolbar:
                        title: "Story"
                        anchor_title: 'left'
                        pos_hint: {"top": 1}
                        elevation: 10
                        left_action_items: [['menu', lambda x: nav_drawer.set_state()]]


            MDNavigationDrawer:
                title: 'Story A Day'
                id: nav_drawer
                swipe_distance: 10

                ContentNavigationDrawer:
                    id: content_drawer
                    screen_manager: screen_manager
                    nav_drawer: nav_drawer

1 Ответ

0 голосов
/ 04 мая 2020

Проблема в том, что в вашем файле 'kv' есть два правила для построения MainScreen, и оба выполняются. Вы должны объединить два правила в одно, чтобы вы могли ссылаться на различные части MainScreen, чтобы помочь в позиционировании. Например, добавление id к MDToolbar позволяет позиционировать ScrollView под ним. Вот так:

<MainScreen>:
    BoxLayout:
        canvas:
            Color:
                rgb: 0, 0, 0, 0
            Rectangle:
                pos: root.pos
                size: root.size
ScreenManager:
    id: screen_manager

    MainScreen:
        name: 'main'

        NavigationLayout:

            ScreenManager:

                Screen:

                    MDToolbar:
                        id: toolbar  # id for use below
                        title: "Story"
                        anchor_title: 'left'
                        pos_hint: {"top": 1}
                        elevation: 10
                        left_action_items: [['menu', lambda x: nav_drawer.set_state()]]

                    ScrollView:
                        #  use toolbar id to position the ScrollView
                        pos_hint: {'top': 1.0 - toolbar.height / self.parent.height}
                        Label:
                            text:
                                """
                                A boy and a girl were playing together. The boy had a collection of marbles. The girl has some
                                sweets with her. The boy told the girl that he would give her all his marbles in exchange for the
                                sweets with her. The girl agreed.
.
.
.

Ваш kv файл слишком сложен из-за того, что он делает. Я не делал никаких упрощений, потому что у вас могут быть причины, по которым вы это делаете.

...