Lately I’ve been working on a simple little text editing aspect of my android app, and i have to say it’s a right pain in ma butt.
First I have the edit box at the bottom of the screen (under a list) and i wanted to have it float up when the screen resizes (when the keyboard shows up)… There was no way to accomplish this. Not at least that I’ve found yet. All the methods to move a control on the screen don’t actually appear to work. I tried to set the position with the layout params, but it doesn’t repaint the control. I tried to animate the control after i moved it. No joy.
IT seems that if the control falls off the bottom of the screen when the screen resizes, then it doesn’ get painted when i move it.
Ok, so i kludged the issue by getting rid of the list, and making the edit box fill the screen…
Oh, and what a wonderful thing happened then. The cursor, was in the middle of the control. That was a puzzler, but a quick google search brought me to setting the gravity to top. Now the text cursor was at the top.. Why i had to set it explicitly is puzzling. Just a small thing but honestly why default to middle?
The hardship has not ended. Now that i have my text aligned and i’ve accepted that the edit will fill the screen, i have a few other tasks.
1. Place the cursor down where the user taps.
2. Store the text when the user changes it..
First. Why do i have to type one little bit of code to set the cursor position. Setting the cursor where the user taps seems an obvious. Why is it not the default on the control?
At this moment, i have posed the question on SO, and twitter. Fingers crossed i find the answer there. I will of course continue to search for something that just “should be”.
The second thing was an odd adventure. A text edit control where getString doesn’t get the text in the box. GetText doesn’t either. I don’ have my code with me as i type this, but that i had to google how to get the text out of a text box was such a little pain in the butt.
This simple little app is being delayed one pin-prick at a time.
Here’s hoping my “one week to write app” doesn’t take yet another fortnight.