pythonkivykivy-languagekivymd

MDButton with kivymd not does not show the correct size when port to android


I made an application using KivyMD where when I run it on the computer it appears normally as shown in the image below:

https://ibb.co/mGpXHZc

But when port to android this happens:

https://ibb.co/vPM044k

How can solve that? follow ky code:

MDButton:
        id: usbButton
        size_hint: None, None
        size: 115, 115
        md_bg_color: 1, 1, 1, 1  # White background
        pos_hint: {"center_x": .50, "center_y": .48}
        on_release: root.manager.current = 'ScreenUSB'
        MDButtonIcon:
            icon: "usb"
            color: "black"
            font_size: "48dp"
            pos_hint: {"center_x": .5, "center_y": .5}
        MDButtonText:
            text: "USB"
            bold: "true"
            color: "black"
            font_size: "10dp"
            pos_hint: {"center_x": .5, "center_y": .12}

Solution

  • For the size you should use 'sp' both for the size_hint and font_size this will make it more consistent as android phones have different resolutions. Using 'sp' makes it consistent across the board. Try it.