Tuesday, 18 September 2012

Background jerk problem because of keypad - Phone gap

In our phone gap application many times we encounter the problem of background. In this problem background image moves up when soft keypad comes up. In some cases all elements on screen like buttons, text fields moves up more than necessary.
In order to keep your screen and background fix you can use following solutions,

1. For keeping your elements on screen fix, you can use "overflow: hidden;" in your css for that element. You can apply this css to the div in which all elements are present.

2. By using above solution elements on screen will become fix but background image may move up. In order to fix background as well as elements you have to add just one line code to your activity tag present in manifest file. 

Code:
 <activity
            android:windowSoftInputMode="adjustPan"
            android:name=".Test"
            android:label="Test"
            android:configChanges="orientation|keyboardHidden" >
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
 </activity>
Here you have to add line in red color. You can try different options of that property.

No comments:

Post a Comment