Kivy页面布局覆盖另一页以防止重叠

时间:2017-07-21 22:54:23

标签: android python kivy page-layout

在Kivy,我在第一页上拉第二页后试图覆盖第一页。目前,列表中的单词重叠,因为页面看起来是透明的,第二页不包括第一页。我尝试改变小部件的背景颜色,但无济于事,甚至尝试在某个阶段添加背景图像。请帮助我占用了足够的时间。如果可能的话,我会很感激纯python而不是kv语言的解决方案。例如:

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.pagelayout import PageLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.core.window import Window
from kivy.graphics import Color, Rectangle

# Window.clearcolor = (252, 235, 233, 0)

class MyScreenManager(ScreenManager):
    pass

class PageLayoutScreen(Screen):
    pass

class PageLayout1(PageLayout):
    def __init__(self, **kwargs):
        super(PageLayout1, self).__init__(**kwargs)

        myList = ['hello there', 'hello to you too']
        t = 0
        for i in myList:
            nameWdgt = Label(text="[b]" + myList[t] + "[/b]", markup=True, font_size='15sp')
            locationWdgt = Label(text="[b]" + myList[t] + "[/b]", markup=True, font_size='15sp')
            self.add_widget(nameWdgt)
            self.add_widget(locationWdgt)

            # below is my attempt to cover the first item in the list "hello there" when we pull the second item in the list over it "hello to you too"
            with self.canvas.before:
                Color(0, 1, 0, 1)  # green; colors range from 0-1 instead of 0-255
                self.profile_layout = Rectangle(size=self.size, pos=self.pos)
            t += 1

root_widget = Builder.load_string('''
#:import NoTransition kivy.uix.screenmanager.NoTransition
#:import sys sys
MyScreenManager:
    transition: NoTransition()

    PageLayoutScreen:

<PageLayoutScreen>:
    name: 'test'
    PageLayout1
''')

class ScreenManagerApp(App):
    def build(self):
        return root_widget

ScreenManagerApp().run()

1 个答案:

答案 0 :(得分:0)

默认情况下,by_kontr %>% group_by(KONTR) %>% do(dplyr::left_join(data.frame(KONTR = .$KONTR[1], DATE = seq(min(.$DATE)+1, max(.$DATE)+1, by="1 month")-1), ., by=c("KONTR", "DATE"))) 是透明的,而不是纹理(文本),这就是您看到重叠的原因。您创建背景的尝试只是用它的默认大小绘制了一个矩形。您需要为每个标签绘制背景,以查看正在进行的操作。

编辑:我不确定您使用LabelScreenManger尝试完成的工作,因此我将其排除在外。

以下是一个例子:

Screen