我正在使用kivy在python中编写聊天应用程序。我正在努力使聊天的主要部分-屏幕两侧的文本消息(大小相同)也可以滚动,就像whatsup /电报/普通消息聊天一样。
我尝试使用ScrollView和RecycleView,但不能使Labels不能占据所有屏幕宽度,并且不能同时使用不同的侧面。
BoxLayout:
orientation: 'horizontal'
#recycle view - freinds list
RV:
spacing: 10
size_hint: 0.25,1
viewclass: 'SelectableLabel'
id: chats
SelectableRecycleBoxLayout:
default_size: None, dp(56)
default_size_hint: 1, None
size_hint_y: None
height: self.minimum_height
orientation: 'vertical'
BoxLayout:
orientation: 'vertical'
canvas:
Color:
rgb: (1, 1, 1)
Rectangle:
pos: self.pos
size: self.size
source: 'cryptychat.png'
#this part is where the messages needs to be
BoxLayout:
orientation: 'vertical'
spacing: 10
Label:
text: "testing"
text_size: self.size
size_hint: 0.1,0.1
pos_hint: {"left":1, "top":0}
color: 0,0,0,1
Label:
text: "testing2"
text_size: self.size
size_hint: 0.1,0.1
pos_hint: {"right":1, "top":0}
color: 0,0,0,1
#writing a message
BoxLayout:
size_hint: 1,0.1
orientation: 'horizontal'
Button:
text: "send"
size_hint: 0.1,1
on_press: MainScreen.send_message(type.text)
TextInput:
id: type
size_hint: 0.9,1
hint_text: "type here..."