Column does not scroll to TextField on focus - android

I have a long input page with multiple TextFields inside it. But when a TextField gains focus, the keyboard appears and the Column (which is scrollable) does not scroll to the specific TextField, and sometimes the keyboard overlaps the field.
I tried to see if this is an Android issue, and no, in normal Android View, the focused TextInputLayout will make the ScrollView scroll so that it's showing.
I tried using RelocationRequester in Compose when the TextField gains focus, but it doesn't seem to do anything, and it only has one method.
Is there a fix to this? Or do I need to wait until Focus and Relocation APIs are stable in Compose?

Related

Android - focus an input textfield inside a webview

I have a problem to focus an input textfield inside a webview. In the webview a text input field is shown. If you click inside, the keyboard opens and the navigationbar is shown as required. The problem is, that the keyboard hides the input textfield. You can enter the text but you don´t see the input, until you scroll down.
Is there a way to resize the webview so the input text field is shown or to automatically scroll to the textfield?
The immersive mode (for usability reasons - required) is used, so I can´t set the windwoSoftInputMode flag to adjustResize.

Android - trigger adjustResize

I wrapped my form in a <ScrollView> and I set my manifest android:windowSoftInputMode="adjustResize" (default of react native). Now when I manually focus a field with my finger touch event, and the field is covered by keyboard, it successfully scrolls to the field I just pressed.
However, if I pragmatically focus the next field (refToTextInput.focus()), it is not scrolling to that next field (focus does happen). I need the scroll to happen.
How can I trigger the adjustResize again, so it scrolls into view the next field I focused?
Manual focus - good
Here is what happens on manual focusing the password field, screencast:
Programmatic focus - bad - fail
However if my focus is in the "username" field and then I do this.refToPassword.focus() on the onSubmitEditing of the username field. Focus moves to the password input, and the keyboard doesnt flash (this is perfect I don't want the keyboard to flash). HOWEVER, the scroll view doesn't scroll to this field. Here is screencast of programmatic focus:
This is not the exact solution that I am proposing. However, you might consider this as a workaround.
You might consider hiding the keyboard programatically and showing the keyboard again on requesting focus programatically in the next EditText field. So the complete pseudo code for requesting the focus in next field will be something like.
public void requestFocusToNextField(View view) {
view.requestFocus();
hideKeyboard();
showKeyboard();
}
Hope that helps!

Scroll to position in recyclerview when keyboard opens

Problem:
I have an edittext as a password field in a viewholderin a recyclerview. If the user clicks on it, the keyboard will appear below it.
Below the password field is a textview that gives feedback if the password the user has entered is valid. But this textview is not visible, because it is hidden because of the softkeyboard. Only after closing the softkeyboard, it is visible and he will see if the password he entered is correct.
Question:
Is there a way to let the softkeyboard scroll below the textview when the edittext is clicked or is there another way to make the password feedback visible to the user?
I would just put it in a scrollview. Then add bottom padding to the height of the soft board
In this case you have a recycler view. There is a Nested scrollview
but without seeing your code I cannot recommend it. You can also add padding to the recyclerviews last element with the passwords for the same effect. But this design is starting to sound funky.. Maybe its time to break this into its own fragment / activity?
That said this SO looks like your solution
What you're looking for is the Activity's windowSoftInputMode
attribute. You set this in your AndroidManifest.xml file, and give it
a value such as:
adjustResize: "The activity's main window is always resized to make
room for the soft keyboard on screen."
adjustPan: "The activity's main window is not resized to make room for
the soft keyboard. Rather, the contents of the window are
automatically panned so that the current focus is never obscured by
the keyboard and users can always see what they are typing. This is
generally less desirable than resizing, because the user may need to
close the soft keyboard to get at and interact with obscured parts of
the window." adjustResize will probably work for you, as long as you
wrap the layout in a ScrollView. It may have negative effects if you
have a bitmap image in the background, as it will be resized as well,
in which case you may want to use adjustPan instead.
or
More information
is available at the above link.

adjustPan: set the view to pan to

I have a popup that has a multi-line edit text and can appear at arbitrary position atop my application. Currently I have implemented it as a transparent activity. When the keyboard is shown over the popup, it jumps up and the current line is shown above the keyboard (I have the adjustPan flag set).
Now, I want the whole popup to go up and show above the keyboard, not only one line of text box. I was able to achieve this by moving focus to the whole layout when the EditText is focused, but then, well, the EditText loses focus, and I cannot type. Is there any other way way to do this? Or is there a way to focus a view without losing focus on another?

Android: Detect When Soft Keyboard Is About to Show?

Is there a way to detect when the keyboard is about to be presented in Android?
My problem is that I have a ListView with EditTexts in it. When the keyboard is about to be presented, these are quite often redrawn, causing an EditText that was JUST tapped to lose focus and require an extra tap.
My proposed solution is to monitor when the keyboard is about to be shown, check to see which view currently has focus, then after the keyboard is done being shown, restore focus to that view.
However, I have no idea how to detect when the keyboard is "about to be shown" in Android. How would I do this?
(I would also accept an alternative answer that addresses my actual problem: EditText losing focus when keyboard is displayed)
You could do it the other way, create an unique OnFocusChangedListener myListener and set it to all your EditTexts and put a switch inside and store which is the last view getting/losing focus

Categories

Resources