首页 > 解决方案 > 如何增加 BoxLayout --kivy 内的 mdtextfield 的大小

问题描述

我想创建一个具有特定size_hint的文本字段,一旦字段内的文本达到特定的minimum height,文本字段size_hint将设置为None并将激活..使用时看起来很完美。但是当我使用 Boxlayout 时,它的大小似乎没有改变。如果我将它的 size_hint 更改为假设,则文本字段将变为一条线,如果将其保持为 None 并通过属性更改其高度,则大小不会增加..我该如何解决这个问题..除了更改布局之外的任何解决方案,因为只有 BoxLayout 是我想要/使用的东西y_scrollFloatLayoutMDTextField0.7Having mode set to rectangleheight

我的代码::

str = '''
    
MDCard:
    pos_hint : {'x':0.056 , 'top':0.836}
    size_hint : 0.88,0.82
    
    ScrollView:
        do_scroll_x : False
        BoxLayout:
            height : self.minimum_height
            orientation : 'vertical'
            size_hint : 1,None
            spacing : 15
            padding : 55
            
            MDTextField:
                id : input_field_1
                mode : 'rectangle'
                size_hint : None,None
                height : 500            # setting height doesn't seems to work either
                #y_scroll : True if self.minimum_height > 400 else False
                multiline : True

            MDTextField:
                id : input_field_2
                mode : 'rectangle'
                size_hint : None,0.7 # see the result 
                #y_scroll : True
                multiline : True

'''
class My_4app(MDApp):
    def build(self):
        return Builder.load_string(str)
My_4app().run()

非常感谢任何帮助

标签: pythonkivytextinput

解决方案


推荐阅读