【问题标题】:Why kivy giving diffrent result after apk packaging?为什么 kivy 在 apk 打包后给出不同的结果?
【发布时间】:2018-11-18 20:05:18
【问题描述】:

这是我的自定义小部件:-

<Entry@Widget>:
    size_hint: (1, None)
    height: sp(100)
    canvas.before:
        Color:
            rgba: 1, 1, 1, .65
        Rectangle:
            pos: self.pos
            size: self.size

    canvas:
        Color:
            rgba: 1, 1, 1, 1
        Rectangle:
            size: sp(30), sp(30)
            pos: self.right-sp(50), self.center_y
            source: root.status
    Label:
        id: first_letter
        text: root.name[0]
        color: 41/255, 128/255, 185/255, 1
        pos: root.pos
        font_size: sp(50)
    Label:
        text: root.name[1:]
        color: 41/255, 128/255, 185/255, 1
        pos: first_letter.x+sp(70), first_letter.y+sp(40)
        font_size: sp(30)
        size_hint_x: None
        width: sp(200)
        halign: 'left'
        texture_size: self.size
        text_size: self.size
    Label:
        text: root.date
        color: 17/255, 80/255, 122/255, 1
        pos: root.x+sp(50), root.y-sp(10)
        font_size: 10

还有主屏幕:-

class Entry(Widget):
    name = StringProperty('Example')
    date = StringProperty('00/00/0000')
    status = StringProperty('static/right.png')

    def on_touch_down(self, touch):
        super(Entry, self).on_touch_down(touch)
        popup = Mypopup(name=self.name)
        popup.open()
        return True

class MainScreen(FloatLayout):

    def __init__(self, **kargs):
        super(MainScreen, self).__init__(**kargs)
        layout = GridLayout(cols=1, spacing=10, size_hint_y=None)
        layout.bind(minimum_height=layout.setter('height'))
        for i in range(10):
            layout.add_widget(Entry(name='Facebook', date='12/12/2012', status='static/right.png'))
        for i in range(10):
            layout.add_widget(Entry(name='Facebook', date='12/12/2012', status='static/wrong.png'))
        scroll = ScrollView(size_hint=(1, None), height=Window.height)
        scroll.add_widget(layout)
        self.add_widget(scroll)

当我在我的电脑上运行它时,它会给出输出:-

在 apk 中打包并安装后,它看起来像:-

我希望它看起来和我的电脑一样。

【问题讨论】:

    标签: python kivy kivy-language buildozer


    【解决方案1】:

    具有不同屏幕尺寸/分辨率的不同计算机可能无法就这些东西的大小达成一致。出于这个原因,有时在我的个人项目中,我会连接第二台更大的显示器。

    总是有Android studio,您可以使用它来获取模拟器。请记住,它需要为 x86 编译的 .apk 文件,而不是 armeabi-v7a。这是在您的 buildozer 规范文件中处理的。使用 x86 进行仿真,使用 armeabi-v7a 进行手机。

    【讨论】:

      猜你喜欢
      • 2010-10-29
      • 1970-01-01
      • 1970-01-01
      • 2012-06-09
      • 1970-01-01
      • 1970-01-01
      • 2017-04-29
      • 2021-12-07
      • 2020-10-15
      相关资源
      最近更新 更多