android : How to prevent resizing the window when displaying the virtual keyboard
Asked Answered
K

3

21

I am using a tabbed application. There is an EditText my application. When I click on the EditText, the window is getting resized and the virtual keyboard is displaying at the bottom of the window. But the four tabs are displaying at the top of the keyboard.

I do not want to display my tabs, when the keyborad is displaying. Or I do not want to resize my window. My need is just to hide the tabs and other things below the EditText.

I use all options with 'android:windowSoftInputMode' in my manifest. bUT I can not see any differences.

Please give me the solution.

Thank you..

Kalakalaazar answered 3/3, 2011 at 12:38 Comment(2)
are you using RelativeLayout by any chance?Leung
ya, i am using relative layoutKalakalaazar
H
9

When Virtual keyboard comes, the view is not re-sized but it gets moved. See this blog post to prevent this.


See also
    Handling keyboard input in Android

Horeb answered 3/3, 2011 at 12:43 Comment(3)
hi, thank u for the thread. when i use android:windowSoftInputMode="adjustPan" in manifest, I can hide the tabs. But still I am suffering from an issue. The soft keyboardis covering bootom-half of the EditText. This is happening from the uppermost EditText to lowermost EditText. Can u help me for placing the soft keyboard exactly under each EditText?Kalakalaazar
i tried that one also. but the problem is still remains thereKalakalaazar
I know it's late but for any one else looking for solution. In my case Application theme was full screen. So, Just change your app theme it will work as stated and expected...Reck
F
20

I found the solution.. for specially "sencha/phonegap/cordova" users.

Edit the main activity in android manifest file add this attribute.

android:windowSoftInputMode="adjustNothing"

  <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
            android:windowSoftInputMode="adjustNothing"  
            android:label="@string/app_name" 
            android:launchMode="singleTop" 
            android:name="com.company.appName.MainActivity" 
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.Black.NoTitleBar">

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter> 
</activity>
Ferrara answered 16/10, 2014 at 7:18 Comment(0)
H
9

When Virtual keyboard comes, the view is not re-sized but it gets moved. See this blog post to prevent this.


See also
    Handling keyboard input in Android

Horeb answered 3/3, 2011 at 12:43 Comment(3)
hi, thank u for the thread. when i use android:windowSoftInputMode="adjustPan" in manifest, I can hide the tabs. But still I am suffering from an issue. The soft keyboardis covering bootom-half of the EditText. This is happening from the uppermost EditText to lowermost EditText. Can u help me for placing the soft keyboard exactly under each EditText?Kalakalaazar
i tried that one also. but the problem is still remains thereKalakalaazar
I know it's late but for any one else looking for solution. In my case Application theme was full screen. So, Just change your app theme it will work as stated and expected...Reck
R
3

I have the same problem and I don't find the blog post suggested by Mudassir helpful. I don't want my window moved or resized or anything so neither adjustPan nor adjustResize works.
I just want it to leave my windows position unchanged.

I found that I can call getWindow and then set the y position and gravity to top|center_horizontal and that fixes it for windows where they don't overlap with the keyboard when the keyboard appears.

For large windows that are partially covered by the keyboard there doesn't seem to be a solution to prevent the keyboard from pushing them around.

Roccoroch answered 24/9, 2011 at 0:23 Comment(1)
Thanks. After 6 hours: alertDialog.getWindow().setGravity(Gravity.TOP|Gravity.CENTER_HORIZONTAL) works.Renny

© 2022 - 2024 — McMap. All rights reserved.