Hi,
I have created my views almost entirely in code, and have used dip almost everywhere. However when I run my app on a smaller device all the views are too large. I actually want to scale them to be smaller on the smaller devices.
Is there any way to set something globally so that the code scales all dip values differently?
Thanks
Andrew
Have you used 100%x and 100%y ? These should make the Views the correct size and then you use DIP for items in the View or a combination of those and %x and %y where appropriate.
Hi,
For example, I have set up several dialogs with sizes of ~400dip. These display fine on my Galaxy Note 10.1" (my primary test device). However on my Galaxy Note 2 (which has a 5" screen) they display too large to fit on the screen. If I had just used actual pixels they would be fine...
How am I supposed to deal with this without changing everything to %x and %y instead of dip?
You should use a combination of the two, where applicable.
i.e. Main View and Activity 100%x and 100%y
Smaller views percentages of those. .e.g. 2x 50%x 100%y for instance.
I'm afraid I can't see any easy way round this, but if you work top down, then some of the smaller elements will adjust, but ideally 100% is the way to go, then it just 'works' on all screens.
** Actually you might be able to use AutoScale in the designer, which might save you a lot of extra work, or have you already employed that?
It depends on what elements make up your App. Mine are primarily ListView / ScrollView based. I suspect yours aren't, so you'll require a slightly different approach.
Hi,
I have not used the designer very much at all, as most of my views are very complex and adjust themselves depending on user actions.
The problem is with the smaller elements, which I have specified using dip not a %x or %x. Does this mean I have to change my whole code to use that form instead? Surely there's some way of setting how dip works globally?
Have a look at this code module AutoScale.
A reading of folowing chapters in the Beginner's Guide might be useful. 5 Screen sizes and resolutions
8.11.3 AutoScale more advanced examples