UI move upward when keyboard open

  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.. :)


It Solved my problem.

Thanks to all.

<activity
    android:name=".AddProductsActivity"
    android:configChanges="orientation"
    android:hardwareAccelerated="false"
    android:windowSoftInputMode="adjustPan" />

Tags:

Android