Proper usage of metrics with Kivy(So GUI scales well across devices)

889 views Asked by At

I am trying to get my game to look/scale well across different devices. I am attempting to introduce the dp and sp metrics into my apps as much as possible, but in this case I am refactoring a game to use these metrics for layout and widget sizing.

Where before, my layouts were sized using size_hint in order to have everything get it's size relative to it's parent(the app itself is not given a size, nor is the window, but the root widget/layout has size_hint=(1, 1)), I am now faced with replacing this system with dp values, and can't figure out what they should be.

I am thinking, that if I just size the root widget, App itself, or Window with dp, then I could continue to use size_hinting, as this would have a trickle down effect and scale everything correctly from the top on down, so to speak. And for this, It seemed like getting the resolution or density of a devices screen would be a great help(so I could use it to size my root widget/App/Window, per device). Is that possible with Kivy? Will this work? Is there a better way? What would you do? Thanks

1

There are 1 answers

1
inclement On

Using size_hint alone already guarantees a degree of scale independence, as (as you note) all the sizes will be relative.

Kivy internally checks some resolution related values of the device, and this is basically the point of dp; something like dp(10) for instance should be the same actual size on any device, in terms of real size on the screen in e.g. centimetres. This won't actually be quite right, if nothing else I think devices don't report precisely right results, but unless this is very important it will already take care of making things mostly look the same anywhere.

I'm not sure what you mean about setting the App size - in Android's window manager an App just fills the screen (at least in most cases).