In this code, I need the spinner dropdown to be adjusted to a particular height... Normally when I add many values it just covers the screen and then has the scrollview... But I need it to be fixed to a particular height... Is it possible? if so, how?
Main Code:
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.lang import Builder
from kivy.uix.widget import Widget
from kivy.uix.screenmanager import Screen,ScreenManager
class Main(Screen):
pass
class Manager(ScreenManager):
pass
kv=Builder.load_file("test2.kv")
screen=Manager()
screen.add_widget(Main(name="main"))
class Test(App):
def build(self):
return screen
Test().run()
Kv Code:
<Main>:
name: "main"
FloatLayout:
id: Fl2
Spinner:
id: number
text: "Select Number"
values: ["ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE","TEN","ELEVEN","TWELVE"]
size_hint: (.3,.1)
font_size: 30
pos_hint: {"center_x":.445,"center_y":.692}
text_size: self.width-dp(30),None
background_color: "#DAA628"
background_normal: ""
color: "#212121"
The Spinner
widget allows you to specify the dropdown_cls
that will be used to display the list of options. So, you can just specify a dropdown_cls
that has a max_height
property set:
<MyDropDown@DropDown>:
max_height: 100
<Main>:
name: "main"
FloatLayout:
id: Fl2
Spinner:
id: number
text: "Select Number"
dropdown_cls: 'MyDropDown' # specify class for DropDown
values: ["ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE","TEN","ELEVEN","TWELVE"]
size_hint: (.3,.1)
font_size: 30
pos_hint: {"center_x":.445,"center_y":.692}
text_size: self.width-dp(30),None
background_color: "#DAA628"
background_normal: ""
color: "#212121"