Android Question ActivitySize vs screen size

Martin Larsen

Active Member
Licensed User
ActivitySize gives the approximate activity size in inches.

On my Huawei P20 Pro (6") ActivitySize=5

Apart from the status bar at the top, the ActivitySize should be equal to the screen size, so why this difference? Am I misunderstanding ActivitySize?

Also, why is ActivitySize not the same in the wysiwyg designer on my phone and in the actual app running on the phone? In the wisywyg designer ActivitySize = 4.78

I show the value using lblActivitySize.text = ActivitySize
 

Erel

Administrator
Staff member
Licensed User
Apart from the status bar at the top
Apart from the status bar, the bottom navigation bar and the title bar.

Also, why is ActivitySize not the same in the wysiwyg designer on my phone and in the actual app running on the phone? In the wisywyg designer ActivitySize = 4.78
The exact numbers are not important. You shouldn't create a layout for any specific size.
The difference might be related to different settings of full screen and title bar.
 
Upvote 0

Martin Larsen

Active Member
Licensed User
Are you hiding the soft buttons = immersive mode?

No, not explicitly but I don't use soft buttons at all. I use gestures, that is swiping from the edges and bottom etc.

The exact numbers are not important. You shouldn't create a layout for any specific size.

I know. I use it for making minor adjustments for small screens:

B4X:
If ActivitySize < 5 Then
    ' do something
End If
 
Upvote 0

Erel

Administrator
Staff member
Licensed User
Anyway, activity size is calculated like this:
B4X:
Dim Scale As Float = GetDeviceLayoutValues.Scale
Dim ActivitySize As Float = Sqrt(Power(100%x / Scale, 2) + Power(100%y / Scale, 2)) / 160
Log(ActivitySize)
The scale is approximated. You can also get the "exact" scale value (set by the manufacturer), however all this discussion is missing the main point - you shouldn't try to target any specific screen size. Use anchors and designer script and build a layout that adopts to all screens.
 
Upvote 0

Martin Larsen

Active Member
Licensed User
Use anchors and designer script and build a layout that adopts to all screens.

That's what I do but I still need to decrease some paddings on small screens.

And I actually got the idea from one of your posts.

It doesn't matter so much that the returned size is not correct, I have just adjusted the comparison accordingly. I just wondered why there was such a big difference.
 
Upvote 0
Top