180

Is there a way to make the screen scroll to allow the text field to be seen?

16 Answers 16

182

I had same issues. Try following code:

android:windowSoftInputMode="adjustPan" 

add it to your manifest.xml in the activity tag of the activity that holds the input. example:

<activity android:name=".Activities.InputsActivity" ... android:windowSoftInputMode="adjustPan" /> 
Sign up to request clarification or add additional context in comments.

7 Comments

Simplest answer! Just as a note, this needs to be added in the Manifest file and under the activity that we want.
In my case, this at least doesn't mess up my html, as adjustResize would do, but it also covers my input fields
@vikifor, make sure you add your edittext into scrollview. Even If you have just 3-4 fields in your layout, add all your fields into scrollview. This makes it scrollable when virtual keyboard opens.
Works fine, but whenever I touch on the EditText view, the keyboard is redrawn.
This not working for me until you press any key, then text field is shown. Scrollview or LinearLayout as root view — doesn't matter.
|
169

Are you asking how to control what is visible when the soft keyboard opens? You might want to play with the windowSoftInputMode. See developer docs for more discussion.

9 Comments

This works fine, but make sure you have <item name="android:windowIsFloating">true</item> in your dialog style, in case you are using custom dialog style.
It seems that this does not work in landscape mode (Nexus 7), editable element stays hidden under keyboard. I tried different combinations of windowSoftInputMode. It seems that I can't set windowIsFloating because ActionBar won't support it. Or it might also have something to do with fact that my EditText is inside list view item?
This won't work after adding <item name="android:windowTranslucentStatus">true</item> in my them. Any one fix this?
@Max Add android:fitsSystemWindows="true" to your root view to solve this.
What about to pull the full layout above the keyboard when soft keyboard is available no matter what like whatsapp....
|
59

I had the same issue where the softkeyboard was on top of the EditText views which were placed on the bottom of the screen. I was able to find a solution by adding a single line to my AndroidManifest.xml file's relevant activity.

android:windowSoftInputMode="adjustResize|stateHidden" 

This is how the whole activity tag looks like:

<activity android:name="com.my.MainActivity" android:screenOrientation="portrait" android:label="@string/title_activity_main" android:windowSoftInputMode="adjustResize|stateHidden" > </activity> 

Here the most important value is the adjustResize. This will shift the whole UI up to give room for the softkeyboard.

4 Comments

But this may mess up your html's look if your css has mostly percentage values
Are you guessing here or did you try it? btw it should not mess up your html. I have tried with webviews. It will be shifting the whole view not individual elements.
I tried it. I think it happens because my css has mostly percentage values
@DanKodi I tried adjustResize|stateHidden and it didn't make any difference from adjustPan.
26

Why not try to add a ScrollView to wrap whatever it is you want to scroll. Here is how I have done it, where I actually leave a header on top which does not scroll, while the dialog widgets (in particular the EditTexts) scroll when you open soft keypad.

<LinearLayout android:id="@+id/HeaderLayout" > <!-- Here add a header or whatever will not be scrolled. --> </LinearLayout> <ScrollView android:id="@+id/MainForm" > <!-- Here add your edittexts or whatever will scroll. --> </ScrollView> 

I would typically have a LinearLayout inside the ScrollView, but that is up to you. Also, setting Scrollbar style to outsideInset helps, at least on my devices.

2 Comments

While Mayra's answer is what everyone should do (and probably what Google thought everyone should do), this is what I end up doing almost every time. It's the only way to get the real control that is needed to make the display correct. Sigh.
don't underestimate Scott's comment. It is true. in my case I didn't want to resize or pan my listview, but wanted to take up the editText at the end of that list. So, I have put editText in scrollView and it works as expected.
18

All you need to do is

android:isScrollContainer="true" 

source: http://www.davidwparker.com/2011/08/25/android-fixing-window-resize-and-scrolling/

2 Comments

While the answer itself didn't help me much (attribute was not needed), the linked source contains the complete explanation (form should be embedded in ScrollView). Thanks!
Likewise, nothing on the page helped me but the link showed adding the adjustResize to the activity windosSoftInputMode and that worked.
15

Sorry for reviving an old thread but no one mentioned setting android:imeOptions="flagNoFullscreen" in your EditText element

Comments

8
android:windowSoftInputMode="adjustPan" android:isScrollContainer="true" 

works for android EditText, while it not works for webview or xwalkview. When soft keyboard hide the input in webview or xwalkview you have use android:windowSoftInputMode="adjustResize"

Comments

4

I believe that you can make it scroll by using the trackball, which might be achieved programmatically through selection methods eventually, but it's just an idea. I know that the trackball method typically works, but as for the exact way to do this and make it work from code, I do not sure.
Hope that helps.

2 Comments

What I think I need is for a way to make the window "artificially" longer so that the view can scroll. Currently the RelativeLayout is set to android:layout_width="wrap_content" android:layout_height="wrap_content"
I do not know of a solution then. Perhaps you might want to manually adjust the width and height values to suit your needs, by stretching them further to that which "wrap_content" is resolving to.
1

add this single line to your relative activity where key board cover edit text.inside onCreat()method of activity.

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); 

Comments

1

just add

android:gravity="bottom" android:paddingBottom="10dp"

change paddingBottom according to your size of edittext

Comments

1

My solution is to put the layout in a ScrollView, If the content is over a screen height, user can scroll to see the whole content and the EditText of the content will fully be seen. If it is at the end of the content, to add enough margin bottom for the view to be shown is necessary.

Comments

0

I know this is old but none of the above solutions worked for me. After extensive debugging, I figured out the issue. The solution is setting the android:windowTranslucentStatus attribute to false in my styles.xml

Comments

0

If EditText Field is been covered by the KeyBoard Use the following code:

 EditText= findViewById(R.id.edittext) EditText?.getParent()?.requestChildFocus(EditText,EditText) 

If you want the Cursor to be in the Focused EditText than use EditText.requestFocus() after the EditText?.getParent()?.requestChildFocus(EditText,EditText) which helps to get the focus and Cursor in the Focused EditText.

Comments

0

The above solution work perfectly but if you are using Fullscreen activity(translucent status bar) then these solutions might not work. so for fullscreen use this code inside your onCreate function on your Activity.

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Window w = getWindow(); w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN , WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN ); getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.TYPE_STATUS_BAR); } 

Example:

 protected void onCreate(Bundle savedInstanceState) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Window w = getWindow(); w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN , WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN ); getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.TYPE_STATUS_BAR); } super.onCreate(savedInstanceState); 

Comments

-1

Edit your AndroidManifest.xml

android:windowSoftInputMode="adjustResize" 

Add this to your root view of Layout file.

android:fitsSystemWindows="true" 

That's all.

Comments

-1

I had the same issue and searching the people said to add adjustPan, while in my case adjustResize worked.

<activity android:name=".YOUR.ACTIVITY" ... android:windowSoftInputMode="adjustResize" /> 

1 Comment

if happened to me, can happen to anyone else, just trying to help ;) @BabyishTank

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.