I'm trying to change the size of my label and TextField, and I'm using MDList with it.
The label and TextField is touching the screen in y axis, both sides. How to padding them for they don't touch the screen? I tried to use size_hint, pos_hint and size, and nothing worked.
from kivymd.app import MDApp
from kivymd.uix.boxlayout import BoxLayout
from kivymd.uix.floatlayout import FloatLayout
from kivymd.uix.button import MDRectangleFlatButton
from kivymd.uix.list import TwoLineListItem
from kivymd.uix.selection import *
from kivymd.uix.textfield import MDTextField
from kivy.lang import Builder
import os
from kivy.core.window import Window
Window.softinput_mode = "below_target"
KV = '''
ScreenManager:
Screen:
name: 'telaAdicionar'
BoxLayout:
orientation: 'vertical'
MDToolbar:
id: toolbar
md_bg_color: 0, 0, 0, 1
TelaAdiciona:
id: telaadiciona
<TelaAdiciona>:
ScrollView:
MDList:
spacing: '20dp'
MDLabel:
MDLabel:
text: 'Text: '
font_style: 'H5'
size_hint: (None, .5)
MDTextField:
id: nomeReceita
font_size: self.width / 30
mode: 'rectangle'
#pos_hint: {'center_x': .5, 'center_y': .5}
#size_hint: (None, .5)
'''
class TelaAdiciona(FloatLayout):
pass
class Aplicativo(MDApp):
def build(self):
return Builder.load_string(KV)
Aplicativo().run()```
The MDList
is intended to be used with BaseListItem . But as it is inherited from GridLayout
you can always use the attr. padding
something like this,
MDList:
spacing: '20dp'
padding: '25dp'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.