Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UI move upward when keyboard open

Tags:

android

I am making the UI of the application. When i tried to enter the value in the EditText then keyboard move the UI upward. Please help me when keyboard open then it should not move the UI upward.

<activity
        android:name=".AddProductsActivity"
        android:configChanges="orientation"
        android:hardwareAccelerated="false"
        android:windowSoftInputMode="adjustResize" />
like image 918
user2601652 Avatar asked Aug 05 '13 13:08

user2601652


People also ask

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

Scrolling up scrollview when keyboard is shown We can add bottom padding into the scrollview using its contentInset property, so the content inside will be moved up when a keyboard is shown. You can think of contentInset as an additional padding extending from the content area edges.

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

How do I stop soft keyboard from pushing up my layout? Add android:windowSoftInputMode="stateHidden|adjustPan" in required activity of your manifest file . This makes keyboard appear overlaying content, without making layout to recalculate it's height.

How do I stop EditText from moving up when keyboard appears?

Try removing the bottom constraint on your EditText, and setting the top constraint on your button to the bottom of the EditText instead of the top of the parent.


2 Answers

It Solved my problem.

Thanks to all.

<activity
    android:name=".AddProductsActivity"
    android:configChanges="orientation"
    android:hardwareAccelerated="false"
    android:windowSoftInputMode="adjustPan" />
like image 54
user2601652 Avatar answered Sep 22 '22 10:09

user2601652


  1. Use RelativeLayout for displaying Top and Bottom bar inside an another RelativeLayout, which covers whole screen.

for top bar :

android:id="@+id/top"
android:layout_alignParentTop = "true"
android:layout_alignParentRight = "true"
android:layout_alignParentLeft = "true"
android:layout_width="wrap_content"
android:layout_height="<fix height like 50dp or as per requirement>"

for bottom bar :

android:id="@+id/bottom"
android:layout_alignParentBottom="true"

  1. Now add a ScrollView like this:

    android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/top" android:layout_above="@+id/bottom"

  2. Now add a child view to this scroll view, which could be any out of RelativeLayout or LineareLayout. We need this child view to just wrap the other child views, which we want to add in the middle of the screen, now anything we want to see, just add that view as a child of this layout like EditText or anything you like.

Now when KeyBoard shows up, the middle scrollview will scroll upside, which won't distort your UI..

I hope it would be helpful, come back to me if you still have problem with this.. :)

like image 40
Prakash Avatar answered Sep 21 '22 10:09

Prakash