Keyboard does not Pan on Android application using PhoneGap

不羁的心 提交于 2019-12-11 07:18:38

问题


I am developing an application using PhoneGap and I cannot get the Soft Input keyboard to work right. As of now I have tried using android:windowSoftInputMode="adjustPan" (resize as well). I have also tried writing getWindow().setFlags(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN, WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST); on my main.java.

I have found a similar problem on google groups https://groups.google.com/forum/?fromgroups=#!topic/phonegap/YFmIeUJBnvQ , and the issue was solved for him but the solution does not for me. Maybe there is something in my code I haven't seen as well. My XML is as follows:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.Comp.Sandbox" android:versionName="1.1" android:versionCode="5">

<supports-screens
    android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:xlargeScreens="true"
    android:resizeable="true"
    android:anyDensity="true"
    />

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.RECORD_VIDEO"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />   
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />   
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17"/>
<application android:icon="@drawable/icon" 
    android:label="@string/app_name"
    android:hardwareAccelerated="true"
    android:debuggable="true">
    <activity android:name="Sandbox" 
            android:label="@string/app_name"
            android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
            android:configChanges="keyboardHidden|keyboard|locale"
            android:windowSoftInputMode="adjustPan"
            android:hardwareAccelerated="true"
            android:screenOrientation="landscape">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

my main.java file is as follows:

    public class Sandbox extends DroidGap
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        super.setIntegerProperty("splashscreen", R.drawable.splash);

        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        getWindow().setFlags(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN, WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST);

        getWindow().setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);

        super.loadUrl("file:///android_asset/www/index.html",5000);
    }
}

Thanks in advance!


回答1:


I ended up making a new project and began adding line per line my code. Apparently there is a problem with android:windowSoftInputMode="adjustPan" on certain devices when you set a Fullscreen theme either with

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); on the main .java file

or

android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" on the activity in the AndroidManifext.xml



来源:https://stackoverflow.com/questions/15749423/keyboard-does-not-pan-on-android-application-using-phonegap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!