Correctly scroll the EditText as a focus

I have an EditText that ultimately resides inside a ScrollView. I have implemented a comment function that will lead you to a new action, and automatically puts focus in the editing text so that the user can immediately start writing his comment.

Unfortunately, it does not quite scroll through the edittext in the form, as you can see in the screenshot below:

Improper Scrolling

I would like to see something similar when EditText opens completely (see below). I already looked at android:WindowSoftInputMode , and it seems that the default values ​​should work ... and indeed, it works mainly because it scrolls, just not enough.

What I'd like to see

So what can I do to achieve the desired behavior? Thanks!

+6
source share
2 answers

Is your minimum SDK 3?

Hope you tried Android: windowSoftInputMode = "adjustPan" and check this .

I would give this one .

+3
source

You can also try to programmatically use this in the onCreate () method for your activity.

 getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); 

" SOFT_INPUT_ADJUST_PAN " found that the window has a window when the input method is displayed, so it does not need to deal with resizing, but simply tinted with a frame to ensure the current input, the focus is visible.

+3
source

Source: https://habr.com/ru/post/910910/


All Articles