Reputation: 27
I have written some code in Python (test.py) and kivy (test.kv).
Can anyone tell me that How to add vertical scrollbar in my boxLayout?
I am using
ScrollView:
do_scroll_y: True
do_scroll_x: False
BoxLayout:
orientation: "vertical"
but I think maybe I'm making a mistake somewhere.
When i am using scrollView then design gets spoiled
from kivy.uix.screenmanager import Screen
from kivy.app import App
from kivy.lang import Builder
from kivy.core.window import Window
Window.clearcolor = (0.5, 0.5, 0.5, 1)
Window.size = (600, 700)
class ACgroup(Screen):
pass
class TestACgroup(App):
def build(self):
self.root = Builder.load_file('test.kv')
return self.root
if __name__ == '__main__':
TestACgroup().run()
<CustomLabel@Label>:
text_size: self.size
#padding_x: 5
<SingleLineTextInput@TextInput>:
multiline: False
<GreenButton@Button>:
background_color: 1, 1, 1, 1
size_hint_y: None
height: self.parent.height * 0.100
ACgroup:
BoxLayout:
orientation: "vertical"
GridLayout:
cols: 2
padding : 15, 15
spacing: 20, 5
row_default_height: '20dp'
size_hint: 1, .01
pos_hint: {'x': 0, 'y':.95}
CustomLabel:
text: 'Fname'
text_size: self.size
halign: 'left'
valign: 'middle'
size_hint_x: 2
SingleLineTextInput:
id: acGroup
size_hint_x: 7
Label:
text: 'Name'
text_size: self.size
halign: 'left'
valign: 'middle'
size_hint_x: 2
SingleLineTextInput:
id: stateName
GridLayout:
cols: 4
padding : 15, 10
spacing: 20, 5
row_default_height: '20dp'
size_hint: 1, .01
pos_hint: {'x': 0, 'y':.7}
CustomLabel:
text: 'ADDRESS :-'
CustomLabel:
CustomLabel:
CustomLabel:
CustomLabel:
text: 'City'
text_size: self.size
halign: 'left'
valign: 'middle'
size_hint_x: 2
SingleLineTextInput:
id: acGroup
size_hint_x: 4.5
Label:
text: 'Pin'
text_size: self.size
valign: 'middle'
halign: 'right'
SingleLineTextInput:
id: stateCode
CustomLabel:
text: 'Area'
text_size: self.size
halign: 'left'
valign: 'middle'
size_hint_x: 2
SingleLineTextInput:
id: acGroup
size_hint_x: 4.5
GridLayout:
cols: 6
padding: 15, 15
spacing: 5, 5
row_default_height: '20dp'
size_hint: 1, .005
pos_hint: {'x': 0, 'y':.5}
CustomLabel:
text: 'Address'
text_size: self.size
halign: 'left'
valign: 'middle'
size_hint_x: 2
#size_hint_y: 2
SingleLineTextInput:
id: acGroup
size_hint_x: 3
#size_hint_y: 2
SingleLineTextInput:
id: acGroup
size_hint_x: 3
#size_hint_y: 0
GridLayout:
cols: 2
padding : 15, 5
spacing: 10, 10
row_default_height: '20dp'
size_hint: 1, .02
pos_hint: {'x': 0, 'y':.4}
CustomLabel:
text: 'CONTACT DETAIL:-'
CustomLabel:
Label:
text: 'Phone'
text_size: self.size
halign: 'left'
valign: 'middle'
size_hint_x: 2
SingleLineTextInput:
id: acGroup
size_hint_x: 6.5
#size_hint_y: 2
Label:
text: 'Mobile'
text_size: self.size
halign: 'left'
valign: 'middle'
size_hint_x: 2
SingleLineTextInput:
id: acGroup
size_hint_x: 6.5
#size_hint_y: 2
Label:
text: 'E-Mail'
text_size: self.size
halign: 'left'
valign: 'middle'
size_hint_x: 2
SingleLineTextInput:
id: acGroup
size_hint_x: 6.5
#size_hint_y: 2
GreenButton:
text: 'Ok'
GreenButton:
text: 'Cancel'
on_press: app.stop()
Can someone help me?
Upvotes: 1
Views: 1070
Reputation: 2645
when you are using a vertical scrollview you must set the height of the only child like this:
ScrollView:
BoxLayout:
size_hint_y: None
height: #the height that you want
Upvotes: 1