Hi,
I have just recently released a new app that relies on textfields.
Having tried everything to get parity for textfield font sizes (or close to) across iOS/Android devices, I ended up going the route of creating a custom placeholder with the textfield off screen.
Now I am getting complaints due to it being non user friendly, ie can’t change text etc.
Would love to hear if anyone has come up with any solutions to getting native textfields font sizes working properly.
Note: I have read every post regarding this infamous issue many times and using:
textfield.size = setfontsize/display.contentScaleY
simply doesn’t work properly.
What I was thinking was this:
Being able to create new non bitmapped text using the native point size (which would require a new api, but should be straightforward):
[lua]
local nativetextheight = 20
local nativetext = display.newNativeText(“Hello”,100,100,native.systemFont,nativetextheight)
[/lua]
then being able to get the contentHeight of the non bitmapped native text in Corona points:
[lua]
local textheight = nativetext.contentHeight – or similar new api call
[/lua]
this would give us the ratio of the corona point height vs the native font height and allow us to set the textfield font size properly for all devices.
[lua]
local ratio = nativetextheight/textheight
–required textfield font size is 24
local textfieldfontheight = 24*ratio
[/lua]
which can be used to set the native textfield font size universally to the same size on all devices like:
[lua]
local textfield = native.newTextField(10,10,100,30)
textfield.font = native.newFont(native.systemFont,textfieldfontheight)
textfield.size = textfieldfontheight
[/lua]
I would love to hear your own solutions to this issue as it urgently needs a fix if it’s to be used properly in business apps.