Android Question Display problem on different devices

yaniv hanya

Active Member
Licensed User
I am developing an app that is supposed to run on multiple screen sizes,
so the size of the controls I calculate in a designer script.
On some devices everything works well, but on one device it comes out twisted.
Do you have any idea why?
I am developing an app that is supposed to run on multiple screen sizes, so the size of the controls I calculate in a designer script. On some devices everything works well, but on one device it comes out twisted.
Do you have any idea why?
This is how it looks on lenovo tab 7
WhatsApp Image 2020-05-11 at 11.20.09 AM.jpeg

This is how it looks on samsung j2
WhatsApp Image 2020-05-11 at 11.20.44 AM.jpeg


and This is how it looks on LG g6 :eek::eek::eek:
2.04.26 PM.jpeg

Do you have any idea why?
the line in the designer that sets the text size are

timeLb.Top=mainPnl.Height*0.10
timeLb.Height=mainPnl.Height*0.18
timeLb.TextSize=mainPnl.Height*0.10

hebDateLb.Top=mainPnl.Height*0.27
hebDateLb.Height=mainPnl.Height*0.1
hebDateLb.TextSize=mainPnl.Height*0.04

fDateLb.Top=mainPnl.Height*0.34
fDateLb.SetLeftAndRight(0,100%x)
fDateLb.Height=mainPnl.Height*0.1
fDateLb.TextSize=mainPnl.Height*0.04
 

Attachments

  • WhatsApp Image 2020-05-11 at 11.20.44 AM.jpeg
    WhatsApp Image 2020-05-11 at 11.20.44 AM.jpeg
    70.7 KB · Views: 146
  • WhatsApp Image 2020-05-11 at 11.20.44 AM.jpeg
    WhatsApp Image 2020-05-11 at 11.20.44 AM.jpeg
    70.7 KB · Views: 149

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. Please use [code]code here...[/code] tags when posting code.
2. Linear scaling of the layout is a mistake in most cases. Better to use anchors and remove all of this code.
3. This line is wrong:
fDateLb.TextSize=mainPnl.Height*0.04
Just delete it.

It is wrong because Panel.Height value depends on the device scale and text size is scaled internally (you don't use dip units when setting the text size).
 
Upvote 0

yaniv hanya

Active Member
Licensed User
Is there no way to calculate the size of the letters I need while running.
There are other labels that are created only at runtime, according to changing information,
the size of which I calculate only by screen size so I can determine the textsize in them?
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Upvote 0
Top