Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Can we get the full screen height and width (in inches) for current device?
Started by troylyndon Mar 27 2019 09:26 PM

6 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

troylyndon

[GLOBAL: userInfoPane.html]
troylyndon
  • Contributor

  • 571 posts
  • Corona SDK

Does Corona give us any way to determine the full screen height and width, physically (in inches) so that I can have a larger UI appear if there is enough space physically for someone's finger?



[TOPIC: post.html]
#2

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 616 posts
  • Corona SDK

If you are using native, you can get a display's DPI on Android that way. Otherwise you should be able to get them via https://docs.coronalabs.com/api/library/system/getInfo.html#androiddisplayxdpi (I'm not sure as to why there is a different DPI command for width and height).

After you get the DPI, you can solve the physical size of the screen for Android devices.

For iOS devices, since there aren't that many of them, you could write a short nested statement that checks for what the device is and then picks its DPI from a list.



[TOPIC: post.html]
#3

thomas6

[GLOBAL: userInfoPane.html]
thomas6
  • Contributor

  • 936 posts
  • Corona SDK

I have another solution: I have a slider in my settings that sets the interface size. That way people can customise according to device but also personal preference. Works really well, and it allows a 10-year old skinny boy or girl to have a smaller interface size than a 300-pound Samoan giant would prefer, even thought they both use the same device.



[TOPIC: post.html]
#4

troylyndon

[GLOBAL: userInfoPane.html]
troylyndon
  • Contributor

  • 571 posts
  • Corona SDK

how about iOS?



[TOPIC: post.html]
#5

thomas6

[GLOBAL: userInfoPane.html]
thomas6
  • Contributor

  • 936 posts
  • Corona SDK

iOS does not allow you to get physical screen size through any API.

 

What you can get, however, is the model specification of the iOS device running your app. Using this you can then derive the physical screen size, because you know which device it is, and can look up the information for this device. But this is a sort of 'dumb' approach, not automated.

 

Another drawback to this is that you only have the info for past and current iOS devices. If a new model comes out you won't know what the screen size will be, unless you update the app to incorporate this new information.



[TOPIC: post.html]
#6

thomas6

[GLOBAL: userInfoPane.html]
thomas6
  • Contributor

  • 936 posts
  • Corona SDK

Video of my "adaptive scaling" attached. ZIP file because the forum doesn't allow .mp4 files for some reason.

 

Don't pay too much attention to the graphics - mostly temporary skins to first make sure things work.

Attached Files



[TOPIC: post.html]
#7

troylyndon

[GLOBAL: userInfoPane.html]
troylyndon
  • Contributor

  • 571 posts
  • Corona SDK

@thomas6, thank you




[topic_controls]
[/topic_controls]