例如,在将新条目添加到RecycleView数据后,我们如何确保最后添加的项目显示在列表底部,而无需手动向下滚动列表?
答案 0 :(得分:1)
经过一番搜索,我认为您可以将scroll_y
的{{1}}属性设置为RecycleView
,然后最后一个条目应该位于{{1 }}。
答案 1 :(得分:0)
此处是应用John Anderson发布的解决方案的kv文件的摘录。注意第一条评论...:
BoxLayout:
size_hint_y: None
height: "70dp"
RecycleView:
id: request_RecycleView_list
size_hint_y: 1
scroll_y: 0 # forces scrolling to list bottom after adding an entry
effect_cls: "ScrollEffect" # prevents overscrolling
viewclass: 'SelectableLabel'
SelectableRecycleBoxLayout:
default_size: None, dp(20) # height of list line
default_size_hint: 1, None
size_hint_y: None
height: self.minimum_height
spacing: 0.5
orientation: 'vertical'
multiselect: False
touch_multiselect: False
<SelectableLabel>:
# Draw a background to indicate selection
canvas.before:
Color:
rgba: (1, 0, 0, 1) if self.selected else (.0, 0.9, .1, .3)
Rectangle:
pos: self.pos
size: self.size
Color:
rgba: (0, 0.9, .1, .3)
Rectangle:
pos: self.pos
size: self.size