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

前端 未结 3 1225
执笔经年
执笔经年 2020-12-30 23:18

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 t

相关标签:
3条回答
  • 2020-12-30 23:55

    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>
    
    0 讨论(0)
  • 2020-12-31 00:15

    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

    0 讨论(0)
  • 2020-12-31 00:16

    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.

    0 讨论(0)
提交回复
热议问题