I got this code to detect screen resolution below. However, my Iconia A500 is spec'd to have a screen resolution of 1280x800 but the code 'detects' it at 1280x752 at 160dpi.
Can anyone see what might be causing the 752 finding when it's an 800 screen? Also, the dpi isn't 160, it's 149 (although 160 is close enough but I'm just wondering why it doesn't get that number).
B4X:
Sub Get_Screen_Resolution
pScreenWidth=GetDeviceLayoutValues.Width
pScreenHeight=GetDeviceLayoutValues.Height
pScale=GetDeviceLayoutValues.Scale
If pScale= 0.75 Then
pDPI="120"
End If
If pScale= 1 Then
pDPI="160"
End If
If pScale= 1.5 Then
pDPI="240"
End If
If pScale=2 Then
pDPI="320"
End If
End Sub
Yes...so that means it is returning 752 because that's what is usable?
Hmmm...for other devices that I don't have to test on, I don't know if they have soft keys or not. I was hoping to detect the full screen resolution because I can find thos published specs for any device (especially when I don't have one to test with).
You will have to setup your app to FULL SCREEN, you can do that using the designer Project -> Activity Properties and check Full screen and uncheck Include title.
However, systems with permanent on-screen-softkeys might still use part of the screen and you will not get an actual resolution.
I personally prefer using percentages for layouts (i.e. 90%x, 66%y). Of course it depends on the type of app you are making and if it would work for your layouts.
You will have to setup your app to FULL SCREEN, you can do that using the designer Project -> Activity Properties and check Full screen and uncheck Include title.
However, systems with permanent on-screen-softkeys might still use part of the screen and you will not get an actual resolution.
You will have to setup your app to FULL SCREEN, you can do that using the designer Project -> Activity Properties and check Full screen and uncheck Include title.
However, systems with permanent on-screen-softkeys might still use part of the screen and you will not get an actual resolution.
Hmmm...I guess I'll have to have a setup screen where the user selects the closest screen resolution to their device. I'm positioning my UI components by % of the screen resolution so I think if they select a close screen size the components should position close enough.
I got this code to detect screen resolution below. However, my Iconia A500 is spec'd to have a screen resolution of 1280x800 but the code 'detects' it at 1280x752 at 160dpi.
Can anyone see what might be causing the 752 finding when it's an 800 screen? Also, the dpi isn't 160, it's 149 (although 160 is close enough but I'm just wondering why it doesn't get that number).
See Designer - Basic4android Wiki. The scales are not a specific resolution, such as 160. They are a range of resolutions and the ranges actually overlap a little. This is described at the link just given.