androidandroid-fragmentsandroid-activitywindow-soft-input-mode

Android soft keyboard keeps pushing action bar off the screen


I got a fragment which is contained inside a PageViewer which is inside a TabHost inside an activity. The fragment contains only a linear layout with a list view and under it an edit text. I have added a border around the edit text by using an xml of a rectangle shape and adding it as a background.

The activity itself is declared like this:

<activity
        android:name=".MyAcivity"
        android:label="@string/app_name"
        android:theme="@style/CustomActivityTheme"
        android:windowSoftInputMode="adjustPan">

    </activity>

The theme:

<style name="CustomActivityTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
    <item name="android:actionMenuTextColor">@color/blue</item>
    <!-- Support library compatibility -->
    <item name="actionBarStyle">@style/MyActionBar</item>
</style>

When pressing the edit text, the soft keyboard is appearing and it's hiding both the action bar and the tab host. It's also hiding the bottom part of the border around the edit text.

I have already tried switching from adjustPan to adjustResize but adjustResize got no effect at all on the layout and is acting the same as if I didn't declare it at all.

What can be done?


Solution

  • I eventually didn't even need the WindowSoftMode property. What confused me was the fact that the EditText was getting smaller when I pressed it and the soft keyboard was shown. Inside the fragment I had a list which had a height weight of 0.9. When I changed it to 0.85 it was fixed. I guess it was too much for edit text to handle when the keyboard was shown.