Kivy。关于android的奇怪观点

时间:2017-06-07 22:35:00

标签: kivy kivy-language

在Android(仅)设备上,所有小部件都位于左下角并且尺寸较小。我尝试使用size_hint和pos_hint以及FloatLayout,但没有结果。出了什么问题?

这是.kv文件

#:kivy 1.0.0
#:import win kivy.core.window

Widget:

    Label:
        id:TopLabel
        text:'Eye verification app'
        width: self.texture_size[0] + dp(40)
        height: '48dp'
        pos: 40,40
        bold:True
        color:1,0,0,1

    Button:
        id:registrateButton
        on_release:

            app.take_picture('registrate')
        text: 'Registrate'
        width: self.texture_size[0] + dp(40)
        height: '48dp'
        pos: 40,160

1 个答案:

答案 0 :(得分:1)

这就是您的应用在我的电脑上的样子:

On PC

这就是我在Android设备上的外观:

On Android

我猜这对你来说仍然太小,这里有一个让按钮变大的方法:

from kivy.base import runTouchApp
from kivy.lang import Builder

runTouchApp(Builder.load_string('''
#:kivy 1.0.0
#:import win kivy.core.window

FloatLayout:

    Label:
        id:TopLabel
        text:'Eye verification app'

        size_hint: 0.8, 0.2 # to react to the screen's size
        pos_hint: {"top": 0.4, "center_x": 0.5} # to place where we want it on the screen

        bold:True
        color:1,0,0,1

    Button:
        id:registrateButton
        on_release:
            app.take_picture('registrate')

        size_hint: 0.8, 0.2 # the same as previous
        pos_hint: {"top": 0.7, "center_x": 0.5} # top is a little lower

        text: 'Registrate'
'''))

以下是现在的样子:

New PC

在Android上:

New Android