我创建了一个自定义键盘,它在方向改变时无法正确调整大小。我试过 invalidateKeys()
,并手动设置所有键的大小,但没有成功。
最佳答案
我在动态调整键盘 View 的键高时遇到了类似的问题。为了解决这个问题,我做了几件事:
1) 创建一个扩展 Keyboard 类的新类,该类定义了公共(public) getKeyHeight 方法并覆盖了 getHeight 方法。我的原型(prototype)代码:
public void setKeyHeight(int height) {
super.setKeyHeight(height);
}
@Override
public int getHeight() {
return getKeyHeight() * 3;
}
2) 在我的
中定义了一个新方法double height_modifier = 1.5;
int height = 0;
for(Keyboard.Key key : mKeyboard.getKeys()) {
key.height *= height_modifier;
key.y *= height_modifier;
height = key.height;
}
mKeyboard.setKeyHeight(height);
我希望这有助于...
关于android - 如何强制重绘软键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8204325/