11

My activity has android:windowSoftInputMode="adjustResize" and behaves accordingly in Android 2.1:

Before soft keyboard appears

Before soft keyboard appears

With keyboard

Keyboard behavior in 2.1 (good)

However, in Honeycomb the soft keyboard does not resize my layout, it instead covers the buttons:

Keyboard behavior in Honeycomb (bad)

Same behavior on both the 10 inch Galaxy tab and the Motorola Xoom.

I've reworked my layout several times trying to get it to be compatible with Honeycomb, to no avail. The soft keyboard will push up an EditText view, but not the buttons.

Here is a simple app project demonstrating the problem.

Edit: Link fixed.

The layout used:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:layout_alignParentBottom="true">
        <Button
            android:id="@+id/save"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Save" />
        <Button
            android:id="@+id/cancel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Cancel" />
    </LinearLayout>
    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true">
        <EditText
            android:layout_height="wrap_content"
            android:layout_width="fill_parent" />
    </ScrollView>
</RelativeLayout>

The only related issue I've found is this, but disabling hardware acceleration had no effect for me. I also read the Android guide on making your app compatible with input methods, but didn't recognize any solution there.

Am I doing something obviously wrong? Or is this a bug anyone has more info on?

Nathan Fig
  • 14,970
  • 9
  • 43
  • 57
  • Possibly related: if you set the Scrollview height to fill_parent, in Honeycomb the buttons become un-clickable because the Scrollview overlaps the buttons and they lose focus. Not the case in 2.1, though. – Nathan Fig Jul 08 '11 at 16:44
  • It seems to work fine for me in the emulator on 3.1, both with and without `android:windowSoftInputMode`. All I did was create a new project and replaces the main.xml with your layout. I was unable to download your sample project. – Nicklas A. Jul 09 '11 at 06:15
  • @Nicklas Odd, in the emulator I'm finding that both 3.1 and 2.1 exhibit the problem: the soft keyboard covers the buttons. I corrected the link. – Nathan Fig Jul 14 '11 at 15:55

3 Answers3

14

Hi I have checked your code.

please remove below line in "AndroidManifest.xml"

android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"

and then check then adjust size your screen.

If any query plz let me know.

Mehul Mistri
  • 15,037
  • 14
  • 70
  • 94
Nikhil
  • 16,194
  • 20
  • 64
  • 81
  • Whoa you're right - that theme does break the resizing in 3.1! Now why would that be? I'm going to look for an alternative full-screen solution now, but thanks so much for the tip! – Nathan Fig Jul 15 '11 at 18:44
  • I've confirmed that it is the fullscreen part of the theme that breaks it in Honeycomb- which makes sense given that Honeycomb apps are all "fullscreen". I need that setting nonetheless since I'm targeting 2.1, Honeycomb just seems to lack backwards compatibility there. Might submit a bug report when I get the chance. Thanks again! – Nathan Fig Jul 15 '11 at 19:45
  • Nathan, did you submit a bug report for this? – Jeremy Haberman May 01 '12 at 20:30
  • No, I never got around to it - I'm guessing that means this is still an issue, sorry I did not take measures to spare you the same misery :( Will you submit a bug report or shall I go ahead? – Nathan Fig May 03 '12 at 19:54
  • Believe it is being addressed here http://code.google.com/p/android/issues/detail?id=5497&can=1&q=honeycomb%20fullscreen&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars – Nathan Fig Jul 09 '12 at 16:31
3

The adjustResize mode definitely works; you will see it in action throughout the UI.

So the question is: why is it not being set for your app?

First thing you can use "adb shell dumpsys window" to see the information about your window, which will include the soft input mode being set by its WindowManager.LayoutParams. The value printed there is the raw number; look here for its meaning: http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#SOFT_INPUT_ADJUST_NOTHING

If your window does not actually have adjustResize there, then you'll need to dig in and see why that is not getting set. Everything else being normal, if you set that mode on the activity it will be set on the window like always. You'll want to look for something else you are doing that is causing it to be changed in your window.

If your window does have adjustResize selected, then for some reason your view hierarchy is not actually resizing. There are no major differences I know of in the platform that could cause this to not work (and again you can see that it does work elsewhere in the stock UI). The first thing I would suggest doing here is using HierarchyViewer to see what is happening in your view hierarchy.

hackbod
  • 90,665
  • 16
  • 140
  • 154
1

adjustResize will fail when your activity is in fullscreen mode, as tracked here: https://code.google.com/p/android/issues/detail?id=5497&can=1&q=honeycomb%20fullscreen&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars

I found a workaround which worked for me, you might want to try out: https://stackoverflow.com/a/19494006/1241783

Cheers

Community
  • 1
  • 1
Bruce
  • 2,357
  • 5
  • 29
  • 50