我有一个界面布局(cleanscreen.kv):
#:kivy 1.9.1
<CleanScreen>
FloatLayout:
canvas:
Color:
rgb:
0.1, 0.3, 0.6
Rectangle:
pos: self.pos
size: self.size
ScrollView:
GridLayout:
cols: 1
size_hint_y: None
spacing: 10
padding: 10
height: self.minimum_height
canvas:
Color:
rgb: 1, 0, 1
Rectangle:
pos: self.pos
size: self.size
FloatLayout:
id: box_share
size_hint_y: None
和 Python 文件(cleanscreen.py):
#! /usr/bin/python2.7
# -*- coding: utf-8 -*-
try:
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.image import Image
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.lang import Builder
except Exception as text_error:
raise text_error
class CleanScreen(BoxLayout):
Builder.load_file("cleanscreen.kv")
def __init__(self, **kvargs):
super(CleanScreen, self).__init__(**kvargs)
self.orientation = "vertical"
self.create_button(self.ids.box_share)
def create_button(self, box_share):
top_logo_share = 1.01
top_button_share = 1.1
top_label_share = 1.4
for i in range(50):
top_logo_share -= .4
top_button_share -= .4
top_label_share -= .4
logo_share = \
Image(source="data/logo/kivy-icon-48.png",
pos_hint={"center_x": .05, "top": top_logo_share},
size_hint_y=None, height=25)
button_share = \
Button(pos_hint={"x": 0, "top": top_button_share},
size_hint_y=None, height=40)
label_share = \
Label(text=str(i), pos_hint={"x": 0, "top": top_label_share},
size_hint_y=None)
box_share.add_widget(button_share)
box_share.add_widget(logo_share)
box_share.add_widget(label_share)
if __name__ in ["__main__", "__android__"]:
import kivy
kivy.require("1.9.1")
class Test(App):
def build(self):
return CleanScreen()
Test().run()
我想得到这个结果:
运行此脚本会在此处显示以下结果:
并且列表没有滚动按钮。我在哪里犯了错误?