Reputation: 321
I'm struggling to get the text in a button to align in the centre of the button, it's just sitting at the bottom of the button.
I've tried changing text_size and font_size to the RoundedButton but nothing has worked so far.
FloatLayout:
RoundedButton:
size_hint: 0.417, 0.15625
pos_hint: {"x": 0.0556, "y": 0.15}
text: "Holding text that isn't aligning in the centre of the button'"
color: 0,0,0,1
text_size: self.width , self.height
halign: "center"
font_size: self.height - 75
<RoundedButton@Button>:
background_normal: ""
background_color: 0, 0, 0, 0
back_color: 0.2,0.6,1,1
border_radius: 10
font_size: '25'
color: self.back_color
bold: True
canvas.before:
Color:
rgba: self.back_color
Line:
rounded_rectangle: self.x, self.y, self.width, self.height, self.border_radius
width: 1
and a trimmed version of the python file:
from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang import Builder
from kivy.uix.button import Button
from kivy.core.window import Window
Window.clearcolor = (1,1,1,1)
class WindowManager(ScreenManager):
pass
kv = Builder.load_file("mykivy.kv")
sm = WindowManager()
class MyApp(App):
def build(self):
return sm
if __name__ == '__main__':
MyApp().run()
Upvotes: 0
Views: 391
Reputation: 321
I've just figured it out, if anyone wants to know the answer in future I had to set valign to "center" (as well as having halign: "center")
Upvotes: 1