KivyMD中对话框尺寸调整异常问题求助
KivyMD对话框显示异常及输入格式问题
我尝试在KivyMD的对话框中容纳MDTextField与自定义键盘,期望对话框能完整显示所有内容,但当前遇到两个问题:
- 对话框背景后出现黑色阴影,显示尺寸设置存在问题;
- 点击按键时,正确格式会短暂弹出后消失。
对话框显示效果对比:
使用的Python代码
def open_keyboard(self): if self.dialog: self.dialog.dismiss() keyboard_content = MDBoxLayout(orientation="vertical", adaptive_height = True) keyboard_content.add_widget(KeyboardContent()) self.dialog = MDDialog( type="custom", content_cls=keyboard_content, size_hint=(0.8, .9) ) self.dialog.open()
对应的Kivy代码
<KeyboardContent>: BoxLayout: orientation: "vertical" MDTextField: id: text_input hint_text: "Type here" required: True max_text_length: 50 GridLayout: cols: 6 spacing: "10dp" MDRectangleFlatButton: text: "A" on_release: root.add_text("A") app.speak_text("a") MDRectangleFlatButton: text: "B" on_release: root.add_text("B") app.speak_text(self.text)
内容的提问来源于stack exchange,提问作者She-Codes
相关产品推荐
相关产品推荐

