Android Question [SOLVED]Some Issue and Question about Screen Size and many device Resolutions

Daniel44

Active Member
Licensed User
Hi everyone!

My script to detect screen size

B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
 
    Dim SCALE As Long
    Dim SIZE As Long
    Dim HEIGHT As Long
    Dim WIDTH As Long
    SCALE= GetDeviceLayoutValues.Scale
    SIZE = GetDeviceLayoutValues.ApproximateScreenSize
    HEIGHT= GetDeviceLayoutValues.Height
    WIDTH= GetDeviceLayoutValues.Width
    MsgboxAsync("LA MEDIDA DE TU PANTALLA ES: " & SIZE  & "  ALTURA: " & HEIGHT & " ANCHO: " & WIDTH & "  ESCALA: "& SCALE, "INFO")
End sub


ISSUE:
Based on this script (I don't know if I'm doing it right) I saw something that I can't figure out. I have a Motorola G8 PLUS and a G9 PLUS. As you can see the one on the left (MOTO G9 PLUS) is taller than the one on the right (MOTO G8 PLUS) BUT THIS SCRIPT TELLS ME THAT THE HEIGHT OF THE MOTO G9 IS LOWER THAN THE MOTO G8 HOW CAN THIS POSSIBLE?.
I know that ApproximateScreenSize is not exact but I think there is a mistake here. Maybe I have a bad concept of resolutions and sizes.

QUESTION
I have a project that if I run it on these phones everything adapts moderately well but if I run it on my other phone a SAMSUNG J2 CORE which is smaller the BXTables do not look good as well as the buttons and labels and their font I must change them.

Now my question is there any way for an app to detect these sizes and change what should be changed in the components (BXTables, Spinners, labels etc.) in the Main or should I do it Activity by activity according to the device?

I leave the sizes and images that according to this script has detected. Thanks to all in advance

SAMSUNG J2 CORE

SCREEN SIZE 4'
HEIGHT 888
WIDTH 540
SCALE 1.5


MOTO G8 PLUS

SCREEN SIZE 5'
HEIGHT 2081
WIDTH 1080
SCALE 2
---------------------------
MOTO G9 PLUS

SCREEN SIZE '5
HEIGHT 1473
WIDTH 720
SCALE 1
----------------------
BLUESTACK CONFIGURED AT 720 X 1280 240DPI

SCREEN SIZE '6
HEIGHT 1280
WIDTH 720
SCALE 1
---------------------------
PIXEL 3 GOOGLE

SCREEN SIZE '5
HEIGHT 2028
WIDTH 1080
SCALE 2
 

Attachments

  • PARA FORO.png
    PARA FORO.png
    435.7 KB · Views: 145
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
do it Activity by activity according to the device?
You shouldn't use activities at all. Switch to B4XPages.

BUT THIS SCRIPT TELLS ME THAT THE HEIGHT OF THE MOTO G9 IS LOWER THAN THE MOTO G8 HOW CAN THIS POSSIBLE?.
Why are you using Longs? Use Int for the width and height and use Float for the size.
Why are you writing with all caps?

You need to divide the width or height by the scale to find the meaningful dimension.
 
Upvote 0

Daniel44

Active Member
Licensed User
You shouldn't use activities at all. Switch to B4XPages.


Why are you using Longs? Use Int for the width and height and use Float for the size.
Why are you writing with all caps?

You need to divide the width or height by the scale to find the meaningful dimension.
Thanks Erel Sorry I didn't realize caps. Well BxPage... I tried but I have some issues and I stopped working with them.
About calcs you.'re saying is there any tutorial? I've been searching for that can you cite any example? Thanks
 
Last edited:
Upvote 0

Daniel44

Active Member
Licensed User
II will continue working with activities because they meet my needs and I see no problems except for passing data from one activity to another, in which case I use global variables and not in all my projects.
 
Upvote 0

Daniel44

Active Member
Licensed User
There are exactly 0 known issues with B4XPages. If you encountered any problem then start a new thread and I'm sure that it will be solved.
I did post the problem I had with that B4XPage. Nobody couldn't help. I've been searching for that post and I couldn't find it. But it's ok can you answer the problem about this post? How can I change component's size according the device or if could see any post about that maybe?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
did post the problem I had with that B4XPage. Nobody couldn't help
As I wrote, there are exactly zero known issues with B4XPages. You are welcome to start a new thread about any issue you encountered.

I already gave you the answer:
Your assumption that the height value has any meaning without normalizing it with the scale, is wrong.

How can I change component's size according the device
Start with using anchors and the designer script.
 
Upvote 0

Daniel44

Active Member
Licensed User
As I wrote, there are exactly zero known issues with B4XPages. You are welcome to start a new thread about any issue you encountered.

I already gave you the answer:
Your assumption that the height value has any meaning without normalizing it with the scale, is wrong.


Start with using anchors and the designer script.
Yes you're right you said I wrong using long values and the calcs I should do that was an issue but my question in this post was not answered by you. Exist some way to change the components size with any function at once? Or should I do that in each activity one by one. Thank you
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
xist some way to change the components size with any function at once? Or should I do that in each activity one by one. Thank you
If you create a layout and put views in it and set anchors like top-left, stretch-horizontal, etc. then when you load the layout in different phone size then the all the views will expand or contract as the case maybe, by default.

If you see that it expand or contract more than desirable, then you can write designer script and use N%x or something similar to adjust the view size depending on screen size.
 
Upvote 0

Daniel44

Active Member
Licensed User
If you create a layout and put views in it and set anchors like top-left, stretch-horizontal, etc. then when you load the layout in different phone size then the all the views will expand or contract as the case maybe, by default.

If you see that it expand or contract more than desirable, then you can write designer script and use N%x or something similar to adjust the view size depending on screen size.
Thank you
If you create a layout and put views in it and set anchors like top-left, stretch-horizontal, etc. then when you load the layout in different phone size then the all the views will expand or contract as the case maybe, by default.

If you see that it expand or contract more than desirable, then you can write designer script and use N%x or something similar to adjust the view size depending on screen size.
Hey @AnandGupta thank you for answering Well I got what you're saying. My main issue in different devices are the Fonts and BX4Tables.. The font looks bigger and that makes other componentent do not look good in the screen for instance BX4Tables. BX4Tables they look big which makes their end not visible

In the designer I have checked the anchors and they are perfect and I have added more variants. The default 320 x 480 160dpi then I have added 720 x 1280 and one more 1080 x 2280 and each one I have checked their anchors and they are perfect. But when running my app on a small cell phone as it is a Samsung J2 Core the ends of the BX4Tables are not visible because the phone browser covers them and the fonts in the labels are large. So what I did in each Layout is not working.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
ends of the BX4Tables are not visible because the phone browser covers them and the fonts in the labels are large. So what I did in each Layout is not working.
I don't know what you mean by the ends are not visible on the B4XTable. There are ways to auto size the columns if that's what you mean. Sometimes, you need to show what you are doing in a small reproducible project so people can help you. You can talk about it all you want, but sometimes demonstrating what it is doing via your code can get you a lot of help.
 
Upvote 0

Daniel44

Active Member
Licensed User
I don't know what you mean by the ends are not visible on the B4XTable. There are ways to auto size the columns if that's what you mean. Sometimes, you need to show what you are doing in a small reproducible project so people can help you. You can talk about it all you want, but sometimes demonstrating what it is doing via your code can get you a lot of help.
Hey @Mahares thank you for answering when I said the ends of the table I was referring to the final edge of the BX4table, those edges are covered by the browser where the navigation buttons of the cell phone are in the case of the smaller phone. As far as giving an example, you are right, but I don't think it is something difficult to understand in my poor English what is happening in my project. Many of you have surely gone through these problems and as you know there are also projects where you can not show it because they are from a client and have sensitive data. Anyway Thanks @Mahares
 
Upvote 0

Daniel44

Active Member
Licensed User
Upvote 0

Daniel44

Active Member
Licensed User
Can you check the original B4XTables example on that phones and get a screenshot to show your issue?
Hola Daniel, ¿puedes probar el ejemplo original en esos dispositivos y subir una captura de pantalla? No hay datos sensibles.

I couldn't reproduce the error in that zip José. Maybe cause the example is made with BXPages. I'm working with activities. But I decided to show some censured pic of my project
 

Attachments

  • MOTO G8 PLUS.png
    MOTO G8 PLUS.png
    84.1 KB · Views: 159
  • PIXEL 3 GOOGLE 1080X2009 SCALE 2.75(440DPI)ANDROID11.png
    PIXEL 3 GOOGLE 1080X2009 SCALE 2.75(440DPI)ANDROID11.png
    51.8 KB · Views: 148
  • SAMSUNG J2 CORE.png
    SAMSUNG J2 CORE.png
    313.8 KB · Views: 159
  • BLUESTACK 720x1280 scale 1.5(240dpi).png
    BLUESTACK 720x1280 scale 1.5(240dpi).png
    58.5 KB · Views: 156
Upvote 0

Daniel44

Active Member
Licensed User
I have frozen the first 2 columns so if I slide the screen to the left I can still see data. What worries me is that on the pixel android google and on the j2 you can't see the button I put at the bottom and on the j2 you can't even see the edge of the B4XTable. All pics are from the same layout
 
Upvote 0

asales

Expert
Licensed User
Longtime User
Put 3 panels in the layout:
- 1 adjusted to the top
- 1 adjusted to the bottom
- 1 with set top and bottom between the above panels. Fill the B4xTable in this panel.
 
Upvote 0

Daniel44

Active Member
Licensed User
Well.. I could solve it adding some variants in the designer

B4X:
AutoScaleAll
If ActivitySize >= 4 Then'<----------J2 CORE
   TBLALLTRAD.Height = 65%y
  btnIngresarNuevo.Top = TBLALLTRAD.Bottom+3dip
  Else If ActivitySize >= 5 Then
  TBLALLTRAD.Height = 75%y
  btnIngresarNuevo.Top = TBLALLTRAD.Bottom+3dip
Else
  TBLALLTRAD.Height = 100%y
  btnIngresarNuevo.Top = TBLALLTRAD.Bottom+3dip
End If


Thank you All!!. Gracias @José J. Aguilar !
 
Upvote 0
Top