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.
Related
An EditText at the bottom of a ListView when pressed, hides the ActionBar. My first problem was to prevent the background image of ListView to shrink. Somehow i overcame my issue. But dnt know how to tackle this one. Can any body guide me? Thanx in advance.
Edit(Explanation)
like a chat window in Viber or Whats App, i have a EditText at the bottom, a ListView in the center and an ActionBar at the top. when i clicked the EditText , the background image shrinks/squeeze. I used adjustPan to overcome this. Its fine. But now, when the soft Keyboard appears, it hides the ActionBar/TitleBar.
Use adjustResize instead of adjustPan. The framework will always try to keep the focused element on-screen by scrolling any parent views if necessary.
If your EditText field is not nested in some sort of scrolling container such as a ScrollView then your layout may be too tall to completely display when the keyboard resizes your activity. Try wrapping your form's layout in a ScrollView. This will also allow your app's content to scroll if it is running on a smaller screen device where it may have similar issues.
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 have a pretty complex layout that has multiple types of views and I have one AutoCompleteTextView that keeps focus. I have relativeLayouts which I keep set to GONE and then when I expand them the screen shoots back up to the autoCompleteTextView which is annoying when you are way down the view. How can I keep the AutocompleteTextView from keeping focus without setting it to not being able to take focus because when you do this you cant click on it to write in it. I tried setting it to not take focus and adding an onclick listener where I basically said if not in focus take focus but that didnt work. I would like to be able to have it so I can start the activity with the AutoCompleteTextView having no focus and then when someone clicks on it they can write in it and when they are done it loses focus. Any help on the matter would be much appreciated.
Place this on its parents layout (like linearLayout):
android:focusable="true"
android:focusableInTouchMode="true"
This way LinearLayout will take focus when user join your activity and the keyboard will not show.
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.
I would like to change the layout when an EditText is clicked and the softkeyboard is shown, so all EditText views are still visible.
I know that you can use the following two, but this is not what i'm looking for.
android:windowSoftInputMode="stateUnchanged|adjustPan">
android:windowSoftInputMode="stateUnchanged|adjustResize">
I've got 8 EditText views spread over the whole screen. When one is clicked to change a value I would like to still see all the ET views but nicely arrange and not pushed in a weird view.
Is there an easy way to do this?
I think you are going to have to do this yourself, but one technique might be ...
Create a layout with the views arranged for the keyboard shown (for instance a new RelativeLayout) that overlays your standard layout. Set it's visibility to GONE. Then when you detect the event that shows the keyboard hide the current view and show the alternate one
I suppose you could also use a ViewSwitcher
If you are using both at the same time then it doesnt work.Set the attribute android:windowSoftInputMode="adjustPan" only.That should work.