09-21-2011 03:40 AM
I just wanted to know if there was any other way besides scaling using base screen dimensions,to resize buttons in an app,so that they remain in proportion to the screen no matter what the dimensions..i.e no matter what the model used 9850 or 9930 or any other using OS 7.0
I tried using certain factors which were common to both the screens dimensions 640x480 and 800x480.But I just dont think its a generalised enough approach.
Solved! Go to Solution.
09-21-2011 06:31 AM
I agree that just using dimensions is not generalized enough. You need to factor in the actual screen resolution. And then, if it is a touch screen, things like buttons need to be large enough to hit with fat fingers....
Here is code that might help:
int screenResH = Display.getHorizontalResolution();
int screenResV = Display.getVerticalResolution();
float PIXELS_IN_ONE_CM = ((float)Math.max(screenResH, screenResV)) / 100f;
Now if you are on a touch screen then the button should be I think at least .7 cm to be big enough to hit. And you can calculate that using the above and so button size will look the same size on all devices and be equally easy to hit.
Another alternative is to take the default font and use its height to factor things. This will mean your scaling will vary depending on what the user has specified. So if your user has very good eyes and has specified a small font size to get more data on their screen, then you will scale to smaller sizes. On the other hand, old blind people like me will see big images.
The down side of this is that all devices will look different. There is an argument that says people want their app to look the same everywhere. Personally I don't think that is possible on a BlackBerry.
Does this help?
09-22-2011 01:22 AM
Thanks for your reply Peter.:-)
I already tried something similar,i used a display.getHeight method to get height of display and i used that along with factors like 0.025 which are common to both screen sizes 640x480 and 800x480,The problem is it won't work for any other screen resolutions.
or i could take a base screen size like 320x480 and use that for scaling the devices screen sizes.and get the button size from that
But i just wanted a 2 knw if a different,more effective approach was possible.
09-22-2011 04:51 AM
I am not sure you have understood what I was saying.
I think it is important to scale things so that
1) they are legible on the screen
2) The user can interact with them.
So I ignore the actual number of pixels on the screen in terms of laying things out. Instead the code I have given you is intended to calculate the number of pixels used in 1 cm on the screen. So you can scale using that to make sure that things are big enough. So regardless of the screen, I can take and scale it to a specific size on the screen - visible size, not number of pixels.
Exactly the same thing happens to fonts. If you look on the BlackBerry you can change the font. But the sizes you specify are points, they are actual size on the screen. So if you select BlackBerry Alpha Sans, 8 on a 9900, the and then ask if how high it is
it returns a result in pixels. If you do the same thing, using the same font, on the Torch, you will find that the number of pixels used on the Torch is a lot smaller. The font is the same physical size on the screen, but uses more pixels on the 9900 because the actual resolution of that screen is higher.
There is a confusion here. Most people, I believe incorrectly, use the term screen resolution to mean the number of pixels on the screen. To me that is just the screen size, The resolution is the pixels per inch. And pixels per inch is what the code I gave effectively calculates (I use centimeters because I am not in the US and cm is more commonly used here than inch).
Anyway, I don't think you understood what I was saying before and you thought I was just doing the same as you. I don't think I was. Please read it again and see if you understand better now.
09-22-2011 08:31 AM