I have trouble implementing the EditText below.
This would be the behavior of the EditText.
After the user enters a text and presses done, a textview with a grey background would be created in front of the edittext. eg. Apple, Banana. The cursor would then reposition in front of the created TextView.
The user would be able to place the cursor between Apple and Banana and upon backpress, the textview before the cursor would be removed.
In case the width of the elements inside the EditText exceeds the screen, you would be able to scroll horizontally inside.
I have tried creating a parent LinearLayout with an underline background which has a RecyclerView and EditText inside. Upon enter, I would add an element in the RecyclerView and increase it's width while the EditText inside will be positioned in front of the RecyclerView which would work in some scenarios but is a very sloppy workaround and won't work in scenario 2.
I haven't found anything that has encountered this same scenario which explains how but I think have seen this same behavior in various apps.
Any help would be greatly appreciated! Thank you!
Regards,
Related
I have an EditText. When I click on it, the input keyboard shows up with the EditText directly above it. I want the keyboard to show up a little bit further down at another View, as if the keyboard is focusing on that. Is there a way to handle this?
My use case is I have two EditTexts and a Button in vertical LinearLayout. I want it so that when I click on either of the EditTexts, the keyboard will popup and still show all three Views.
Best practice, you won't want that, i.e showing all views while the keyboard is showing. This will force android to squeeze the views when there isn't enough space.
Best option is try adding paddingBottom to your EditText an example being android:paddingBottom="15dp" This should align the keyboard 15 pixels below your EditText.
You could also use ScrollView as suggested above which allows android to auto handle vertical scrolling for you.
so i have some elements (including an EditText) above my ListView. The EditText is essentially a custom search field that I implemented to add some extra functionality to the filtering of the ListView. The EditText cannot be a header of the ListView because I don't want it to scroll off screen as you go through the list.
All works well, except on smaller devices. The screen does not scroll when you are entering text in the EditText so you can't see the live-filtering within the ListView.
Usually you would make the parent item in the layout file a ScrollView and define the activity's windowSoftInputMode as adjustResize, but this is not an option due to the fact that I have this ListView within the layout and it is a sin to have a ListView within the ScrollView.
Ideally, I'm looking for a way to make the following happen:
-upon the EditText gaining focus, I'd like it to scroll to the top of the page, and the listview occupy the rest of the screen.
-upon the EditText losing focus I'd like the screen to return to it's default state.
so far, the only real way that I'm coming up with doing this is to manually detect the keyboard showing up and then hide the top of the screen, and then upon detecting the keyboard disappearing i would show it again.
can anyone suggest something better that isn't such a hack?
I want to use an EditText to let the user edit input on different positions of a Scrollview (like cells in a spreadsheet). When the softkeyboard is invoked, it moves the screen only as long as the Edittext is on its original location, that was given in the Layout.xml. As soon as I change something like size, location, background, the invoked Keyboard does not move the screen, but covers the Edittext when it is in the way. Same when I use adjustResize.
Is there a solution beside adding an separate EditText on every possible opsition?
Any help welcome.
Its all about the focus of the view, things will work when system know which view have the focus, in scrollview case the focus is on the scrollview hence things will not work accordingly.can see this for more information.
This one bothers me for quite a while. I have an app where the user paints some objects with fingers. One is supposed to be a Text Box, a rectangular where the user can input text, like the one word provides (http://www.techrepublic.com/i/tr/cms/contentPics/r00319991202jod05_01.gif)
I do not need the text to be painted dynamically, I launch another activity where the user adds text and I catch the text on activity result. But I need the user to be able to reshape the object and it should handle all the cases like:
i. Box too narrow for the text -> get the last words to another line
ii. Box too narrow for some single words -> split the words
I want to handle this exactly like word text box handles it. I thought it could me by dynamically making a textView, but it seems impossible. I posted a question here Android - create TextView (or EditText) programmatically and set it in a specific place on the screen giving coordinates (mostly about textView) but I had no luck, drawTextOnPath can work for i but it is very hard to implement ii and show text in a smooth way.
I know we are not supposed to ask the same thing twice, but I do it to explain in a new way what I need, which leads to a different question. Thanks to everybody in advance.
Moving the Text around can be done easily by dragging the view in onTouchEvent.
Scaling the text can be done using two finger gesture. Just like the zoom feature in Webview. You should increase the textsize of the TextView on zoom-in and decrease on zoom-out.
Update:
Resize the TextView itself when two finger gesture is on. That will automatically re-flow the text appropriately. TextView can be resized by calling setHeight and setWidth.
Declare a LinearLayout with TextView as the only child.
Inflate this layout when needed and set the margins for the textview to position it appropriately.
When resizing just change the height and width of the textview.
I have a number of EditTexts inside a scrollview. In the background these fields are linked to a number of other fields and regularly (once a second or so) the layout has it's textfields updated depending on the values in the EditText.
The problem is if one EditText has focus at the top of the ScrollView and the user scrolls the view done (i.e. so the focused EditText is off screen), but if the update is made to the views, the scroll view moves up to focus on the EditText at the top of the view.
The closest I have got to remedying this is to make the scroll view change focus when scrolling however this is still has the same behaviour but at a reduced scale.
Does anyone have an idea of how I can stop this from happening?
Cheers,
Matt
You can try using EditText#setFocusable around your code that updates the value. I haven't tested this but if the problem is that it is getting focus when you use setText() it may help.