My input text is cut off halfway on some Android devices!! PLS HELP!

It’s still totally cut off by using the code you suggest (getAndroidFontSize).

The upper half is always cut off. I don’t understand why increasing the height for the input bar or find a good font size can solve this problem?

I make the input box large enough but the texts are placed in the upper half. If I increase more height or decrease the font size, it will only make it odder and odder.

Before I give it up, anyone can sum up the finalized solution? Maybe I miss something.

I can’t use input text if this problem is not solved.

What’s the ultimate solution for this?

Does it exist?

Hi @joe528,

Did you test our sample app for text entry? This uses a fairly simple conditional statement to adjust for Android.

CoronaSDK > SampleCode > Interface > NativeKeyboard

Thanks,

Brent

I can’t use input text if this problem is not solved.

What’s the ultimate solution for this?

Does it exist?

Hi @joe528,

Did you test our sample app for text entry? This uses a fairly simple conditional statement to adjust for Android.

CoronaSDK > SampleCode > Interface > NativeKeyboard

Thanks,

Brent

Hi,

i am also not able to get it working. I only need a simple highscore text input field which works on all devices. I use the following config file:

application = { content = { width = 800, height = 1200, scale = "letterBox", fps = 60, imageSuffix = { ["@2x"] = 1.3, }, }, }

with the “standard” (320x480) config file the solutions and also the CoronaSDK > SampleCode > Interface > NativeKeyboard are working. But not with my 800x1200 config.

Any help is very appreciated. Thanks.

Thomas

Can you give us a better description or screen shots or something more than “it’s not working”.

Rob

Hi Rob,

i tried it with your example on the second page but with my config file (800x1200). Here is the code:

local fontSize = 22 / display.contentScaleY print(fontSize) print(display.contentScaleY) local yearIF = native.newTextField( (display.contentWidth / 2), 180, (display.contentWidth\*0.45), fontSize\*3) yearIF.font = native.newFont( native.systemFont, \_G.fontSize ) yearIF.size = fontSize yearIF.text = "" yearIF:setTextColor( 81/255, 81/255, 81/255 ) yearIF.inputType = "number"

I only changed the font size from 12 to 22 and set the height of the text field to 3*fontSize.

The result on a Nexus 4 is that the text is cut off halfway. Is there any formula how big the height of the text field must be compared to the font size? 3*fontSize seems not enough.

P.S.

If i take your original values:

local fontSize = 12 / display.contentScaleY

and height of text = 35 i do not see any chars in the text field with my config file.

Android has more “chrome” around their text fields that have to be accounted for.  If you look at the native.textField sample apps you will see for Android we add some extra height.  It’s not predictable as to how much you need because all android devices are different.

Rob

So if the text height is not predictable native.newTextField is useless. It is very frustrating. I only need a highscore name input field. What is your implementation in your apps? 

If you’re on Android, make the field height higher, perhaps 50% + 10-12 pixels.  So if your iOS field is 30 pixels high, then on Android make it 55 pixels.

Rob

Hi Rob,

that would be great if it would be so easy. But if you have a look at my example my height was three times bigger ( fontSize*3) than the font size and that was not enough on my device. At the moment i believe the native objects do only work with 320x480.

Is there any save calculation for the dependency between font size and text field height (config is 800x1200)? ny Little example would be helpful.

Thanks

Thomas

What is the value _G.fontSize?

Is there a reason you have a global version of this and a local version?

What is the value of display.contentScaleY and your fontSize calculation?

I built this code:

local fontSize = 22 / display.contentScaleY \_G.fontSize = fontSize print(fontSize) print(display.contentScaleY)     local yearIF = native.newTextField( (display.contentWidth / 2), 180, (display.contentWidth\*0.45), fontSize\*3)     yearIF.font = native.newFont( native.systemFont, \_G.fontSize )     yearIF.size = fontSize     yearIF.text = ""     yearIF:setTextColor( 81/255, 81/255, 81/255 )     yearIF.inputType = "number"

For my Nexus 7 running 4.4 and the text fits the box perfectly.  I used an 800x1200 content area.

Rob

Hi Rob,

very frustrating. On my Nexus 4 running 5.0 (same with 4.4) the text is cut off half way.

The calculated fontSize = 21.12 and display.contentScaleY = 1.04

So every device is different? Or the content scaling has some influence? We have different behaviours on different device resolutions.

Can you post a screen shot from the device? 

Also what is the value of that global variable version of fontSize?

Rob

It’s been a year and a half since I joined this thread. It’s really disappointing when people join it, acknowledging that this is still such a problem. I still don’t have every device covered in my app (I gave up). At least have some kind of official triggered shim input where you don’t even render the real input box, since at least that would be something Corona-controlled without these gymnastics.

Sorry Rob,
i do not see any possibility to upload an attachment on this forum. If i click on “My Media” i have no button to upload anything. how can i upload screen shots?

Hi @toga,

You can upload images by clicking “More Reply Options” (instead of just “Post”). Then, on the next screen, you’ll see an option to choose a file and upload it.

Brent

Also post your config.lua please.

Rob