Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android : Showing keyboard moves my components up, i want to hide them instead

I have added a LinearLayOut having some buttons My screen is RelativeLayOut it self

Here is the code for that linear layout manager

<LinearLayout     android:orientation="horizontal"     android:gravity="bottom"     android:layout_alignParentBottom="true"     android:layout_height="wrap_content"     android:layout_width="fill_parent"     android:id="@+id/Footer"     android:layout_marginBottom="5dp"> 

Here is the problem:

There is an EditText component on the top and it pops a soft keyboard on the screen , and brings my Footer manager on top of the keyboard and eventually SHATTERS my whole UI.

What is the exact solution?

P.S. I have removed android:gravity="bottom" and android:layout_alignParentBottom="true" one by one but with hard luck i did not get desired result.

Thanks

like image 771
Prasham Avatar asked Nov 29 '10 06:11

Prasham


People also ask

How do you hide keyboard on Android?

You can force Android to hide the virtual keyboard using the InputMethodManager, calling hideSoftInputFromWindow, passing in the token of the window containing your edit field. This will force the keyboard to be hidden in all situations.

How do you move the layout up when the soft keyboard is shown Android fragment?

Set fitsSystemWindows = "false" and set android:windowSoftInputMode="adjustResize" in manifest file. Show activity on this post. I have used like this to show the soft keyboard programatically and this is worked for me to prevent the auto resize of the screen while launching the keyboard.


2 Answers

Add android:windowSoftInputMode="adjustPan" to manifest - to the corresponding activity:

  <activity android:name="MyActivity"     ...     android:windowSoftInputMode="adjustPan"     ...   </activity> 
like image 158
Asahi Avatar answered Oct 08 '22 05:10

Asahi


You probably want

<activity      ...    android:windowSoftInputMode="adjustNothing">  </activity> 

That will prevent any layout changes when the soft keyboard is shown.

There is probably some confusion over this since it's currently missing from the documentation at http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft

like image 35
aaronvargas Avatar answered Oct 08 '22 06:10

aaronvargas