My Octopress Blog

A blogging framework for hackers.

If windowSoftInputMode Does Not Work

| Comments

Activity has an element windowSoftInputMode to interact with a on-screen soft keyboard.

There are many suggestions How to adjust layout when soft keyboard appears, but sometimes it does not work.

Why?

Because we set it at AndroidManifest.xml.

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

But if we use a theme in our application this property is overrided:

1
2
3
4
5
<style name="Theme">
...
        <item name="android:windowSoftInputMode">stateUnspecified|adjustUnspecified</item>
...
</style>

Hence we need to override it in our theme:

1
2
3
<style name="NameActivity" parent="@android:style/Theme.Holo.NoActionBar">
     <item name="android:windowSoftInputMode">adjustResize</item>
</style>

After we can use it at AndroidManifest.xml:

1
<activity android:theme="@style/NameActivity" android:name=".NameActivity"/>

Comments