I am using multiTab in kivy. How to enlarge the scrollbar so that scrollbar can be moved(up_down) by mouse. I am using BoxLayout and RecycleView. The code below was working with gridLayout, but not in BoxLayout:
layout.bind(minimum_height=layout.setter('height'))
Here is an example of how to extend ScrollView to also get a dragable slider.
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
from kivy.uix.label import Label
Builder.load_string("""
<ScrollSlider>:
ScrollView:
id: scrlvw
bar_width: 0
GridLayout:
id: grid
size_hint_y:None
cols:1
height: self.minimum_height
scroll_y: slider.value
on_touch_move: slider.value = self.scroll_y
Slider:
size_hint_x: None
width: root.width*0.2
id: slider
min: 0
max: 1
orientation: 'vertical'
value: scrlvw.scroll_y
on_value: scrlvw.scroll_y = self.value
""")
class ScrollSlider(BoxLayout):
def custom_add(self, widget):
self.ids.grid.add_widget(widget)
class MyApp(App):
def build(self):
scrollslider = ScrollSlider()
for i in range(1, 100):
scrollslider.custom_add(Label(text=str(i), height=100, size_hint_y=None))
return scrollslider
if __name__ == '__main__':
MyApp().run()
You need to use the custom_add
to add widgets in the ScrollSlider
or add them to the GridLayout
in kivy.
I took some inspiration from the link @Edvardas Dlugauskas provided.
The code you provided does not work with BoxLayout
because BoxLayout
just takes the size of its parent. To be able to scroll you need to add sth into ScrollView
which is larger than the ScrollView
itself.