Reputation: 101
If I create a kivy app with a resolution of 800x600, with full screen set, and run this app on an android, will the resolution automatically fit the android's screen (without black borders)?
If not,
What would be the correct python way to assure a full fit screen on any device?
-------update 9:41pm----------
I imported Kivy's metric module and used dp() on size measurements.
If GW.width != Windows.width: GW.size = (dp(Window.width), dp(Window.height))
Would using dp() and sp(fonts) ensure correct full screen scaling for multiple devices?
Upvotes: 3
Views: 3634
Reputation: 7349
I doubt that hard-coding a resolution into the device is ever the way to go, except maybe when testing your app with different resolutions.
I think the best way to ensure that you're app will fit a devices screen is to make use of the size_hint
and pos_hint
attributes of the various widgets that you use in your GUI. This will generally size and position your widgets relative to their parents/containers. And as far as I am aware, the 'top-level' app Window
itself will automatically take up the full screen on the device. So everything within it should then be scaled and positioned relatively.
Also, when you do specify the size of a widget or font, the use of 'dp'
and 'sp'
respectively goes a long way to ensuring that sizing is appropriate across devices. Example: font_size: '20sp'
or Label(text='bleh', font_size='20sp')
There is also no need to import the metrics module to use them in this manner(in the kv file in any case)
Myself, I tend to use size_hint
and pos_hint
for sizing and position a lot of my widgets, and I would use 'sp'
for font sizes and probably 'dp'
only for things like paddings and spacings etc.
Here are links to relevant docs:
EDIT:
In response to your extra question, that looks like it could indeed work. However, personally I prefer to use size_hint
and pos_hint
as I find it more intuitive and just simpler. The best way to know is to just experiment.
Upvotes: 2