当输入焦点时,JQuery Mobile不适合屏幕

时间:2012-11-09 03:32:39

标签: android jquery cordova jquery-mobile

我正在使用PhoneGap和JQuery Mobile for Android开发应用程序。

我在登录页面上有2个输入,并且一切正常,但是当我对输入进行聚焦时,页面将不适合屏幕并且可以是水平滚动。在取消聚焦输入框后,页面再次适合屏幕。

不关注输入框
http://imageshack.us/a/img90/9909/device20121109111004.png

专注于输入框,页面右侧约2px http://img3.imageshack.us/img3/7078/device20121109111036.png

<div data-role="content">
        <form id="loginForm">
            <ul data-role="listview" data-inset="true">
                <li><div data-role="fieldcontain" class="ui-hide-label">
                        <input type="text" name="username" id="username" placeholder="username" autocomplete="off" />
                    </div>
                    <div data-role="fieldcontain" class="ui-hide-label" >
                        <input type="password" name="password" id="password" placeholder="password"/>
                    </div></li>
            </ul>
            <br /> <br /> <input type="submit" value="Login" name="btnSubmit" id="btnSubmit" />
        </form>
    </div>

我该如何解决这个问题?当我专注于输入框时我想要适合屏幕 谢谢

1 个答案:

答案 0 :(得分:0)

AndroidManifest.xml文件中添加android:windowSoftInputMode="adjustResize"到您的主要活动。

例如:

<application
        android:name=".MyAndroidApplication"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name">
        <activity
            android:name=".MyAndroidActivity"
            android:configChanges="orientation|keyboardHidden"
            android:windowSoftInputMode="adjustResize"
            android:label="@string/app_name">

@See Android activity