我正在尝试编写一个聊天应用程序,其界面在可滚动的侧窗格中具有用户名。
我有两个问题:
1-此代码没有滚动,请让我知道我做错了什么:
stacklayout2 = StackLayout(orientation='lr-tb',)
## Scrollview layout
scroll_layout = GridLayout(cols=1,
spacing=20,
size_hint_y=None
)
scroll_layout.bind(minimum_height=layout.setter('height'))
for i in range(10):
scroll_layout.add_widget(ToggleButton(text=str(i),
size_hint_y=None,
height=40
)
)
scrollview = ScrollView(size_hint=(.3,.5), do_scroll_x=False)
scrollview.add_widget(scroll_layout)
stacklayout2.add_widget(scrollview)
stacklayout2.add_widget(Button(text='Send',size_hint=(.2,.2)))
s2.add_widget(stacklayout2)
2-这是将(可单击/可选)用户放在侧窗格上的最佳方式,我做对了?
根据请求重新提交为答案:)
错误在绑定上,
scroll_layout.bind(minimum_height=scroll_layout.setter('height'))
是您需要的,因此scrool_layout高度在更新minimum_heigh时会更新。