By androidcodehunter

2013-07-01 17:44:55 8 Comments

I tried to write a code which is used to re-size the UI components when soft-keyboard appears. When I use adjustResize, it res-size the UI components and at the same time adjustPan gave me same output. I want to know the difference between them and when to use each component? Which one(adjustPan or adjustResize) is good for resizing UI?

Here is my xml:

<ScrollView xmlns:android=""
    android:fillViewport="true" >

        android:layout_height="wrap_content" >

            android:orientation="vertical" >

                android:inputType="textPersonName" />

                android:text="My Button" />


and the menifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
    android:versionName="1.0" >

        android:targetSdkVersion="17" />

        android:theme="@style/AppTheme" >
            android:windowSoftInputMode="adjustPan|adjustResize" >
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />



@stinepike 2013-07-01 17:47:07

From the Android Developer Site link


The activity's main window is always resized to make room for the soft keyboard on screen.


The activity's main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing. This is generally less desirable than resizing, because the user may need to close the soft keyboard to get at and interact with obscured parts of the window.

according to your comment, use following in your activity manifest

<activity android:windowSoftInputMode="adjustResize"> </activity>

@androidcodehunter 2013-07-01 17:54:15

thank you for your nice reply. Now I am having a problem with my UI. I have a edittext and a button at the bottom of my layout. I want to show those above the soft-keyboard when soft-keyboard appears. How can I achieve this. Can you help me to solve this problem?

@stinepike 2013-07-01 17:57:09

check the updated answer

@androidcodehunter 2013-07-01 18:00:27

This is not working for me. Actually what I wanted: I just want to show Edittext and Button above the soft-keyboard when I try to write something in Edittext field. I tried your solution but not working.

@stinepike 2013-07-01 18:03:35

oops .. it worked for me .. anyways .. is it possible to use scrollview?

@androidcodehunter 2013-07-01 18:07:22

Now I am testing code in eclipse using my symphony phone. I have used scrollview but not working for me.

@stinepike 2013-07-01 18:08:04

it would be more clear if you post the manifest xml .. and the layout xml

@androidcodehunter 2013-07-01 18:13:02

I added my xml and menifest file. Please help me.

@androidcodehunter 2013-07-01 18:17:29

@stinepike 2013-07-01 18:22:00

hi Sharifur please check using adjustResize only .. updated the answer

@androidcodehunter 2013-07-01 18:31:19

adjustResize only provide solution when UI is available for re-sizing but if I put 5 more edittext then it cannot works. Is it possible to show button and edittext above the soft-keyboard when UI is not available to re-size. Actually question is arising when I testing this problem.

@IgorGanapolsky 2013-11-11 18:42:21

~"This is generally less desirable than resizing". Well, not if resizing causes your views to overlap on each other. Like when you have a tabbed navigation, and a bunch of views in each tab fragment - on some devices adjustResize may cause the views to overlap when the keyboard is shown. There, unfortunately, you have to set adjustPan if you want to prevent this from happening.

@support_ms 2014-06-19 05:08:43

You should create scrollview as a root layout of your view where keyboard will be shown and replace adjustResize to adjustPan

@IgorGanapolsky 2015-06-09 17:29:28

@support_ms Why ~"replace adjustResize to adjustPan" is necessary?

@support_ms 2015-06-10 11:47:34

@IgorGanapolsky I don't remember that. I answered, when I was also working with that kind of task

@Mark13426 2016-10-04 18:45:37

I don't think adjustPan is required for ScrollView.

@Jayakrishnan PM 2016-10-08 03:06:53

adjustResize = resize the page content

adjustPan = move page content without resizing page content

@TTKatrina 2016-10-08 02:56:13

You can use android:windowSoftInputMode="stateAlwaysHidden|adjustResize" in AndroidManifest.xml for your current activity, and use android:fitsSystemWindows="true" in styles or rootLayout.

@Tomask 2015-11-19 16:26:56

As doc says also keep in mind the correct value combination:

The setting must be one of the values listed in the following table, or a combination of one "state..." value plus one "adjust..." value. Setting multiple values in either group — multiple "state..." values, for example — has undefined results. Individual values are separated by a vertical bar (|). For example:

<activity android:windowSoftInputMode="stateVisible|adjustResize" . . . >

Related Questions

Sponsored Content

96 Answered Questions

[SOLVED] Close/hide the Android Soft Keyboard

30 Answered Questions

25 Answered Questions

[SOLVED] Is there a way to run Python on Android?

34 Answered Questions

47 Answered Questions

[SOLVED] Is there a unique Android device ID?

28 Answered Questions

[SOLVED] What is 'Context' on Android?

77 Answered Questions

11 Answered Questions

[SOLVED] Proper use cases for Android UserManager.isUserAGoat()?

20 Answered Questions

[SOLVED] What is the difference between gravity and layout_gravity in Android?

16 Answered Questions

[SOLVED] What is the difference between match_parent and fill_parent?

Sponsored Content