So here's the problem: You want your items to show exactly the same way on VGA and QVGA screens but Force QVGA just stretches controls on VGA screens and make images pixelated. However drawing every control based on screen resolution is a waste of time and reduces the speed of your application:
How can you double your control sizes without requiring "If Then Else" statements for everything you draw? Erel has already proposed a solution but it doesn't work when drawing stuff at runtime (AddButton, DrawImage, Drawstring...). Here's how I did it for Gecko after much thinking and some swearing:
1-Get the screen resolution
There are many ways to do this. It doesn't matter to know the exact resolution, since all you want to know is whether you will double controls size or not. If Form.Height is bigger than 400, it's VGA. You can also use the Display control from ControlsExDevice or the dzHW library to get more detailed information.
Once this is done, you need to add the following code in your application:
2-Add compatibility to the controls you want to resize by changing from:
to
Voilà!
If VGA=2, control sizes will be doubled. Otherwise, they'll stay the same size. It only requires a few extra lines and avoids the pixel doubling of ForceQVGA
Notes:
If you get the full screen size (and not form.height) to check if it's VGA, be careful! Some libraries will return the full screen size on the desktop version so go to Designer>(any form)>Tools>Screen size and type in a VGA resolution. The font sizes will still look small, but on the device they are the same size as with Force QVGA
B4X:
[COLOR="Red"]'WRONG[/COLOR]
If [I](the screen is QVGA)[/I] then
AddButton("Form1","Button1",5,5,100,25,"Click me")
Else If (the screen is VGA) Then
AddButton("Form1","Button1",10,10,200,50,"Click me")
End If
How can you double your control sizes without requiring "If Then Else" statements for everything you draw? Erel has already proposed a solution but it doesn't work when drawing stuff at runtime (AddButton, DrawImage, Drawstring...). Here's how I did it for Gecko after much thinking and some swearing:
1-Get the screen resolution
There are many ways to do this. It doesn't matter to know the exact resolution, since all you want to know is whether you will double controls size or not. If Form.Height is bigger than 400, it's VGA. You can also use the Display control from ControlsExDevice or the dzHW library to get more detailed information.
Once this is done, you need to add the following code in your application:
B4X:
Sub Globals
VGA=1
Sub App_Start
SetControlSize
'Do your stuff
End Sub
Sub SetControlSize
If Form1.Height>400 Then
VGA=2 '(yes, 2)
Else
VGA=1
End If
End Sub
2-Add compatibility to the controls you want to resize by changing from:
B4X:
Button.Width=20
AddTable("Form1","Table1",0,0,10,10)
B4X:
Button.Width=20*VGA
AddTable("Form1","Table1",0*VGA,0*VGA,10*VGA,10*VGA)
Voilà!
If VGA=2, control sizes will be doubled. Otherwise, they'll stay the same size. It only requires a few extra lines and avoids the pixel doubling of ForceQVGA
Notes:
If you get the full screen size (and not form.height) to check if it's VGA, be careful! Some libraries will return the full screen size on the desktop version so go to Designer>(any form)>Tools>Screen size and type in a VGA resolution. The font sizes will still look small, but on the device they are the same size as with Force QVGA
Last edited: