Kivy: Resolution Behavior

If I create a kivy app with 800x600 resolution, full screen and run this app on Android, will the resolution automatically match the Android screen (no black borders)?

If not,

What would be the correct python way to provide a full screen on any device?

------- update 9:41 pm ----------

I imported the Kivy metric module and used dp () to measure the size.



If GW.width! = Windows.width: GW.size = (dp (Window.width), dp (Window.height))

Will using dp () and sp (fonts) provide proper full-screen scaling for multiple devices?

+3


source to share


1 answer


I doubt it is always possible to hardcoding the permission in a device, except maybe when testing your app with different resolutions.

I think the best way to ensure that your application will fit the screen of devices - use attributes size_hint

and pos_hint

to the different widgets that you use in your GUI. Typically the size and position of your widgets will be relative to their parents / containers. And as far as I know, the "top tier" app Window

itself will automatically take up the entire screen on the device. Thus, everything inside it must be scaled and positioned relatively. Also, when you specify the size of a widget or font, the use of 'dp'

and 'sp'

accordingly goes a long way to ensure that the size is appropriate for all devices. Example: font_size: '20sp'

orLabel(text='bleh', font_size='20sp')

Also there is no need to import the metrics module to use them this way (in the kv file anyway)

I tend to use size_hint

both pos_hint

for sizing and positioning many of my widgets, and I would use 'sp'

for font sizes and maybe 'dp'

only for things like paddings and spacing, etc.

Here are links to related documents:



Kivy metrics

Understanding size_hint

EDIT:

In response to your follow-up question, it looks like it might actually work. However, I personally prefer to use size_hint

and pos_hint

as I find it more intuitive and just simpler. The best way to find out is to just experiment.

+2


source







All Articles