Android Question Strange result for GetDeviceLayoutValues

EduardoElias

Active Member
Licensed User
Longtime User
Hi there,
If someone could help....

I am using the GetDevicePhysicalSize and the return value for one tablet that I have here is strange....

B4X:
Sub GetDevicePhysicalSize As Float
    Dim lv As LayoutValues
    lv = GetDeviceLayoutValues
    Dim size As Float = Sqrt(Power(lv.Height / lv.Scale / 160, 2) + Power(lv.Width / lv.Scale / 160, 2))
    Return size
End Sub

I returns size as 7.89 (I suppose Inch) and it is a 10inch tablet!!

GetDeviceLayoutValues returns 1024 x 720 scale = 1 (160dpi)

Eventually the calculation is right, however this tablet is for sure a 10inch.

What is wrong?

Thank you !
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Note that this functionality is also available by calling: GetDeviceLayoutValues.ApproximateScreenSize.

This results means that this 10'' tablet has a true resolution of a 8'' tablet. It is like a stretched 8'' tablet. You do not need to do anything special about it. With the help of the designer script your layout can fit on tablet (or phone) of any size.
 
Upvote 0

EduardoElias

Active Member
Licensed User
Longtime User
Thank you,

It seemed strange for me.

However the reason of paying attention to this value is because I have 2 very different layouts of the same program. One that is better for small screens, and to take this decision I was trying to identify the device size.

However this is going to be confusing...

There are tablets with 5inch and now Phones with 6inch. I am going to guess and let the user change if needed.

Eduardo
 
Upvote 0
Top