Reputation: 424
I'm trying to do a label with size_hint in a floatlayout but I've realized that doesn't work. I want to make a responsive size of label, because the app wil run in different sizes of screen. I'm doing in kivy language, the code is:
Label:
text: "I'm trying to make a label with size_hint_y"
size_hint_y: 0.6 #doesn't work, always the same size of font
pos_hint: {'center_x':0.5,'center_y':0.36}
Upvotes: 1
Views: 4315
Reputation: 152
I made my font size = the vertical resolution of the screen * the height of the widget * .5. It does not work perfectly, but it seems to work well enough for now. Since your size_hint = .6, I would try
font_size = (Window.size)[1] * .6 * .5
I also added did not use a KV file. I do not know if that will make a difference. My code for a similar program looked something like this
I made variables for the size of the widget and the font size
size = (.2, .075)
fontsize = (Window.size)[1] * size * .5
Then to add the widget
self.button = Button(text = "Press Me", size_hint = size, font_size = fontsize)
Hopefully, this helps!
Upvotes: 3
Reputation: 29488
#doesn't work, always the same size of font
size_hint_y controls the size of the widget, not the font. Use font_size
instead.
Upvotes: 3