1

我一直在研究 Android Sample SoftKeyboard。这有点道理,但我遇到了一个问题。键盘只会填充大约 88% 的屏幕(540 像素屏幕的 480 像素)。

我正在开发 Atrix 4G,显然 2.3.4 存在问题,据我所知,具有 qHD 屏幕的原始设备无法正确显示大多数键盘(这也是 CM7 的问题一段时间) )。我能找到的每个键盘都是固定的,但我不知道他们是如何做到这一点的。

键盘准确地显示了我在模拟器上的期望(屏幕宽度 480 像素),它只是在设备本身上变得奇怪。

示例中似乎控制 IME 宽度的代码如下所示,但即使将其设置为屏幕分辨率的显式宽度也不能解决问题。

/**
 * This is the point where you can do all of your UI initialization.  It
 * is called after creation and any configuration change.
 */
@Override public void onInitializeInterface() {
    if (mQwertyKeyboard != null) {
        // Configuration changes can happen after the keyboard gets recreated,
        // so we need to be able to re-build the keyboards if the available
        // space has changed.
        int displayWidth = getMaxWidth();
        if (displayWidth == mLastDisplayWidth) return;
        mLastDisplayWidth = displayWidth;
    }
    mQwertyKeyboard = new LatinKeyboard(this, R.xml.qwerty);
    mSymbolsKeyboard = new LatinKeyboard(this, R.xml.symbols);
    mSymbolsShiftedKeyboard = new LatinKeyboard(this, R.xml.symbols_shift);
}

编辑:找到至少一个临时的解决方法,禁用兼容模式可以正确呈现应用程序......但不知道为什么这是必要的,因为应用程序是使用正确的 API 版本(Gingerbread/10)部署的。

4

1 回答 1

1

您需要在 Manifest 文件中设置 sdk 版本:

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8" />
于 2012-03-26T09:43:27.787 回答