简体   繁体   English

我正在使用 Kivy 开发一个 Android 应用程序,我想知道如何在 Scrollview 中添加 MDCard? 目前我正在使用 kivyMD 和 Kivy

[英]I am developing an Android app using Kivy and I wanted to know that how can I add MDCard in Scrollview? Currently I am using kivyMD and Kivy

Whenever I try this code I get error and also if I keep only MDCard then also its appears but not in Scrollview.每当我尝试此代码时,我都会出错,而且如果我只保留 MDCard,那么它也会出现但不在 Scrollview 中。 This is my code:这是我的代码:

ScrollView:

    do_scroll_x: False
    do_scroll_y: True

    Label:
        size_hint_y: None
        height: self.texture_size[1]
        text_size: self.width
        padding: 10, 10
        text:
            'My text\n' * 100
    MDCard:
        Label:"Hello"

From the ScrollView documentation :ScrollView 文档

The ScrollView accepts only one child ScrollView 只接受一个孩子

That may be the cause of your error.这可能是您的错误的原因。 Try something like this in your kv file:在你的kv文件中尝试这样的事情:

ScrollView:

    do_scroll_x: False
    do_scroll_y: True

    BoxLayout:
        orientation: 'vertical'
        size_hint_y: None
        height: self.minimum_height
        Label:
            canvas.before:
                Color:
                    rgba: 1,0,0,1
                Rectangle:
                    pos: self.pos
                    size: self.size
            size_hint_y: None
            height: self.texture_size[1]
            padding: 10, 10
            text:
                'My text\n' * 100
        MDCard:
            Label:
                text: "Hello"
                size_hint: 1, None
                height: self.texture_size[1]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 kivy 和 kivyMD 生成数字键盘? - How can I generate the Numeric Keyboard using kivy and kivyMD? 使用 python kivy 构建应用程序时出现错误 - i am getting error while building app using python kivy 我正在开发一个 kivymd 应用程序,但在获得权限后应用程序崩溃 - I am developing a kivymd app but app is crashing after taking permissions 我正在做一个 kivy 项目......我正在使用从函数创建的切换按钮......我怎么知道选择了什么? - im working on a kivy project... i am using toggle buttons that are create from a function... how do i know what is selected? 如何保存我的应用程序的 state? kivy/kivyMD - How do i save the state of my app? kivy/kivyMD 我无法在 python 中使用 kivy 更改屏幕 - I am not able to change the screen using kivy in python KIVY:我可以在滚动视图中设置滚动视图吗? - KIVY: Can I have a scrollview inside of a scrollview? 如何使用 kivy 中的 ScrollView function 制作 FloatLayout Scrollablle - How do I make a FloatLayout Scrollablle using the ScrollView function in kivy 如何使用buildozer将软件包导入Kivy应用程序 - How can I import an package into a Kivy app using buildozer 我正在尝试使用 python 文件在 kivy 中添加标签。 但它每次都抛出错误 - I am trying to add label in kivy using python file. But it is throwing an error everytime
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM