简体   繁体   English

将 kivy 文件 (.py) 转换为 apk 时,小部件不会自动调整为设备的 window 大小

[英]When converting kivy file (.py) to apk, widgets are not automatically adjusting to device's window size

I am trying to develop an andriod app using Kivy.我正在尝试使用 Kivy 开发一个安卓应用程序。 I have used floatLayout to place the widgets.我使用 floatLayout 来放置小部件。 The output, when I run it on my linux is: output,当我在我的 linux 上运行它时:

Output in linux linux中的Output

Then after converting it to apk, the widgets are getting compresed and texts flow out of widget and looking shabby:然后在将其转换为 apk 后,小部件被压缩,文本从小部件中流出,看起来很破旧:

output on android output 上 android

my code: code code我的代码:代码代码

how can I make the widgets get adjusted automatically to the size of device(in my case Andriod).如何使小部件自动调整为设备的大小(在我的情况下为 Andriod)。 So that the texts doesnt flow outside the buttons and looks systamatic as it is in linux.这样文本就不会在按钮之外流动,并且看起来像 linux 中的系统。

First of all, you have to check your kivy app in correct resolutions.So run in cmd: python main.py --size=1440x2960 (phone device screensize opt.You can scale input sizes for your computer screen. Divide by 2/3/4/5..) So you can reedit your code after check in correct resolution. First of all, you have to check your kivy app in correct resolutions.So run in cmd: python main.py --size=1440x2960 (phone device screensize opt.You can scale input sizes for your computer screen. Divide by 2/3 /4/5 ..) 所以你可以在检查正确的分辨率后重新编辑你的代码。

Also you need to use metrics for your font sizes.Example: font_size: '20sp' .您还需要为您的字体大小使用指标。例如: font_size: '20sp' Use sp metrics for scale your fonts for all devices automaticly.使用 sp 指标自动为所有设备扩展 fonts。 Check here for Kivy Metrics Docu.在此处查看 Kivy 指标文档。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM