Android Question Screen Size Problem

David Elkington

Active Member
Licensed User
Longtime User
I was wondering if anyone could point me in the right direction. I have an app that `I have designed for a client which has a large number of different screens. We were using roughly 100 Lenovo tablets with 1920x1200 resolution and all was good.

Lenovo now don't make that 10" tablet any longer so I have bought some 8" Huawei ones instead, again with 1920x1200 resolution.

On opening my app, the screen is not fitting at all, almost looks like it is half the screen being shown. In my code, I have used dip everywhere and the Pixel density on the 8" is 383 which kinda makes sense that it is higher than the 240 of the 10" tablet.

I thought by buying the same resolution screens I would not have to change my app, anyone know why it is not working?

Thanks

Dave
 

corwin42

Expert
Licensed User
Longtime User
The resolution is not enough to take care of. The devices scale is another factor. I guess both devices use a different scale.

How did you create your layouts for the Activities? With the designer? Then I guess it will be possible to create just another variant for the new devices.

For future development you should consider this tutorial: https://www.b4x.com/android/forum/t...creens-tips-and-best-practices.17647/#content
 
Upvote 0

David Elkington

Active Member
Licensed User
Longtime User
I have two Lenovo tablets, one is reporting 10.10 as the screen size and one @ 9.43, but I think they should be both 10. They have different DPI, but the app looks identical to the Pixel so I am not sure it is a scale issue as I have used DIP everywhere.
 
Upvote 0

David Elkington

Active Member
Licensed User
Longtime User
I created a custom 1920x1200 layout with scale factor 1.5 which I think should cater for 240 dpi, so I would have thought the 8" would display smaller than the screen not outside the screen.
 
Upvote 0

eps

Expert
Licensed User
Longtime User
The best way forward is to get the App to resize everything to fit the space available. Then you shouldn't ever have to recode that part.

Something like this :

B4X:
Activity.AddView(TabHost1,0,0,screen_width,screen_height)

Obviously it depends on what your main 'view' is and if you need the full height or not - I make mine slightly 'shorter' so that an advert can be popped in it, but guess that your App won't have this in - have tailored the above.

It might help to see some screenshots or at least an idea of what the App is displaying and how you are arranging the information.

ETA : I guess you've read this https://www.b4x.com/android/forum/threads/supporting-multiple-screens-tips-and-best-practices.17647/
 
Upvote 0

corwin42

Expert
Licensed User
Longtime User
I created a custom 1920x1200 layout with scale factor 1.5 which I think should cater for 240 dpi, so I would have thought the 8" would display smaller than the screen not outside the screen.

No. Dip means "Device independent pixels" so if you use dip values 1 inch on the 10" tablet will also be 1 inch on the 8" tablet. Therefore on the 8" tablet your layout will not fit.

Try this on both devices. You will see that the scale will differ.
B4X:
    Dim lay As LayoutValues
    lay = GetDeviceLayoutValues
    Log(lay.ApproximateScreenSize)
    Log(lay.toString)
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I created a custom 1920x1200 layout with scale factor 1.5 ...
I'm afraid that the problem is this: scale factor 1.5
Do you use AutoScaleAll ?
You should never use a layout variant with a scale factor different from 1.
The operating system will automatically adjust the layout according to the scale factor.
But as you have 1 device type with a scale factor of 1.5 and the other with a factor of 2, I suggest you the following.
For testing make a layout with 1920x1200 and scale factor 1 and see if it works.
As the target devices have almost the same dimensions, another solution would be to position the views in the Designer with %x and %y values.
As eps aleady suggested, could you post a layout file?
 
Upvote 0

David Elkington

Active Member
Licensed User
Longtime User
I do have one question however, I did have 2 layout files in another screen, one was 1280X800 and the other 1920x1200. I made it look good on the 1280 size, and then did a few changes on the 1920x1200 layout, but the tablet never seems to use the 1920 layout at all? Is there a reason for this?
 
Upvote 0

corwin42

Expert
Licensed User
Longtime User
A small tip:

In the B4A program folder is a file called "AbstractLayouts.txt". There you can add a definition for the new tablet. Then you can check with the Abstract designer if your current layout will fit on the new device.
 
Upvote 0

corwin42

Expert
Licensed User
Longtime User
I do have one question however, I did have 2 layout files in another screen, one was 1280X800 and the other 1920x1200. I made it look good on the 1280 size, and then did a few changes on the 1920x1200 layout, but the tablet never seems to use the 1920 layout at all? Is there a reason for this?

I guess you mean 2 variants, not files? I guess again that the first variant is 1280x800 scale 1 and the second is 1920x1200 scale 1.5.
So for B4A they are just the same dimensions. B4A will select the first variant for a 1920x1200x1.5 device because it perfectly fits this device.
 
Upvote 0
Top