Solar2D screen positions for all devices resolution

Result on all devices
Imgur

(black background on top and bottom)

OK. I kind of suspected this might happen.

Here is a new test sample: https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2021/03/screen_bounds_help2.zip

If you’re calling native.setProperty( "androidSystemUiVisibility", ... ) that may be the problem.

We can test around that idea by:

Run the example #2 three times (on your device… yeah It is a pain… sorry):

  1. As delievered.
  2. Edit main.lua and call v2() instead of v1(), then run
  3. Edit main.lua and call v3() instead of v2(), and then run

Please paste the different images if you will.

If you’re NOT calling the setProperty function then… I’ll have to think about this for a bit.

Result is the same for v1, v2 and v3
Imgur

Here is another test you can paste in there…



local results = {}
local function display_params_tester( tag )
	local values = { 
		"actualContentHeight",
		"actualContentWidth",
		"contentCenterX",
		"contentCenterY",
		"contentHeight",
		"contentScaleX",
		"contentScaleY",
		"contentWidth",
		"pixelHeight",
		"pixelWidth",
		"safeActualContentWidth",
		"safeActualContentHeight",
		"safeScreenOriginX",
		"safeScreenOriginY",
		"screenOriginX",
		"screenOriginY",
		"statusBarHeight",
		"topStatusBarContentHeight",
		"viewableContentHeight",
		"viewableContentWidth",
	}

	for idx,name in pairs(values) do
		if( tag == "before" ) then
			results[name] = display[name]
		else
			local out
			if(display[name] == results[name]) then
				out = tostring(name) .. " " ..  tostring(results[name]) .. " " ..  tostring(display[name])
			else
				out = tostring(name) .. " " ..  tostring(results[name]) .. " " ..  tostring(display[name]) .. " !!!! CHANGED !!!!" 
			end
			print( out )
			local l = display.newText(  out, 10, 80 + 20 * idx, native.systemFont, 12 )
			l.anchorX = 0
		end		
	end
end

local function v4()
	display_params_tester("before")
	print()
	timer.performWithDelay( 1000, common.easyAndroidUIVisibility )
	timer.performWithDelay( 2000, function() display_params_tester("after") end )
end

 v4()

This will tell us if values are changing or not when you hide the ui.

re: Your results. That is weird. v3() should be hiding the button ui.

Try replacing common.easyAndroidUIVisibility with your own call to native.setProperty( "androidSystemUiVisibility", ... ) however you do it.

Also, do the values printed for pixelWidth and pixelHeight match the specs of your test device?

I gotta jet pretty soon, but if you have two devices, one that works as expected, and one that does not, I suggest you tweak the latest sample I gave you so that:

On the working device, the app gathers values before hiding the UI, hides the UI (visually verify), and the dumps the values (with any change markers) to the screen.

If you can do that, and if there are values that get changed (IIRC, at least actualContentWidth, and actualContentHeight should change after hiding the UI), then you can run it on the non-working device to see if the values change properly or not.

Result
Imgur

local common = require 'common'

local results = {}
local function display_params_tester( tag )
	local values = { 
		"actualContentHeight",
		"actualContentWidth",
		"contentCenterX",
		"contentCenterY",
		"contentHeight",
		"contentScaleX",
		"contentScaleY",
		"contentWidth",
		"pixelHeight",
		"pixelWidth",
		"safeActualContentWidth",
		"safeActualContentHeight",
		"safeScreenOriginX",
		"safeScreenOriginY",
		"screenOriginX",
		"screenOriginY",
		"statusBarHeight",
		"topStatusBarContentHeight",
		"viewableContentHeight",
		"viewableContentWidth",
	}

	for idx,name in pairs(values) do
		if( tag == "before" ) then
			results[name] = display[name]
		else
			local out
			if(display[name] == results[name]) then
				out = tostring(name) .. " " ..  tostring(results[name]) .. " " ..  tostring(display[name])
			else
				out = tostring(name) .. " " ..  tostring(results[name]) .. " " ..  tostring(display[name]) .. " !!!! CHANGED !!!!" 
			end
			print( out )
			local l = display.newText(  out, 10, 80 + 20 * idx, native.systemFont, 12 )
			l.anchorX = 0
		end		
	end
end

local function hideUI()
	if ( system.getInfo("platformName") == "Android" ) then
		local androidVersion = string.sub( system.getInfo( "platformVersion" ), 1, 3)
		if( androidVersion and tonumber(androidVersion) >= 4.4 ) then
		native.setProperty( "androidSystemUiVisibility", "immersiveSticky" )
		--native.setProperty( "androidSystemUiVisibility", "lowProfile" )
		elseif( androidVersion ) then
		native.setProperty( "androidSystemUiVisibility", "lowProfile" )
		end
	end
end

local function v4()
	display_params_tester("before")
	print()
	timer.performWithDelay( 1000, hideUI )
	timer.performWithDelay( 2000, function() display_params_tester("after") end )
end

 v4()

This code hide bottom navigation bar

result:
Imgur

I understand this and fixed it, thanks @roaminggamer

Congratulations!

I was going to offer another example that re-calculates the bounds… but my guess is you did this already.

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2021/03/screen_bounds_help3.zip

If I am not correct, can you post back your fix or a summary of what you did?

I didn’t know values ​​change when I hide the UI, so I hide the UI first and create the top bar after hiding the UI

@roaminggamer I still have some troubles :confused: On Xiaomi Mi Play 4 and Xiaomi Mi SE8 result:

Weird black top bar, what is it? There is no such bar on the LG K8, LG K10

EDIT: On four differences devices it’s okay, so this bar is only on Xiaomi

That is bizarre. You are setting your background color so it should not be the background.

I’m sorry but that has me stumped.

If you draw a really tall rectangle (say 4 x screen height) does it draw over the black gap? If it does, then that is drawable space. If not, then maybe the whole Corona container is shifted down.

Corona container is shifted down. Is any way to fix it?

Sorry, but I have no solution for that.