Graphics and differing devices

joolzg

Member
Licensed User
Longtime User
Ok i have built my app on a chinese android box and the graphics look right

In Activity_Create
B4X:
    channelInfo.Initialize("channelInfo")
    channelInfo.Color = Colors.ARGB( 1, 128, 128, 128)
    Activity.AddView( channelInfo, 0%x, 70%y, 100%x, 24%y)

Then to draw the information i want

B4X:
      rect1.Initialize(5%x, 2%y, 11%x, 13%y)
      canvas1.DrawBitmap( cCurrent.pIcon, Null, rect1)
      canvas1.DrawText( cCurrent.cNumber, 12%x, 10%y, Typeface.DEFAULT_BOLD, 24, Colors.White, "LEFT")
      canvas1.DrawText( cCurrent.cName, 5%x, 22%y, Typeface.DEFAULT_BOLD, 24, Colors.White, "LEFT")
      canvas1.DrawText( DateTime.Time(DateTime.Now).SubString2(0,5), 97%x, 16%y, Typeface.DEFAULT_BOLD, 30dip, Colors.White, "RIGHT")

Now the icon (cCurrent.pIcon) is 64x64 in size
The time i wanted in a larger font but i wanted this right justified and in line with the top of the icon
The Channel name i wanted to be under the Icon in line with left hand edge of the icon
And the Channel number i wanted just to the right of the icon.

All this is working but when i move to a different device it all gets messed up. the ratios especially the font sizes and positions dont look the same

Any help on this?

joolz
 

klaus

Expert
Licensed User
Longtime User
What are the resolutions and scales of the other devices ?
Be careful, in the first two DrawTeext lines you use 24 for the TextSize but in the third one you use 30dip. You shouldn't use dip values for font sizes.
Another problem is the width/height ratio that isn't the same on all devices.
That means that the width/height ratio of all the views will also vary.
If you are targeting smartphones and tablets and you stretch or shrink all views according to the screen size you should consider different font sizes according to the physical screen sizes and not the resolutions.

Best regards.
 
Upvote 0

joolzg

Member
Licensed User
Longtime User
Thanks i missed the 30dip one, was told to leave them without dip.

Well at the moment i am working on a chinese box which is outputting 1920x1080 and a Samsung Galaxy S2

It looks like i am going to have to have different settings

joolz
 
Upvote 0
Top