I am coding a custom Android soft keyboard app. In the settings page of the app, there…
- User
I am coding a custom Android soft keyboard app. In the settings page of the app, there is a SeekBar that resizes the height of the keyboard.
I am encountering a bug where, when the keyboard is downsized, the keys shrink as expected but the keyboard does not drop down to the bottom of the screen. There is no bug when the keyboard grows in size.
In the input method service's
onStartInputView, I have the following:java@Override public void onStartInputView(final EditorInfo editorInfo, final boolean isRestarting) { super.onStartInputView(editorInfo, isRestarting); for (final Keyboard keyboard : keyboardSet) { keyboard.adjustKeyboardHeight(); } inputContainer.updateHeight(); // etc. }keyboard.adjustKeyboardHeight()applies a multiplier to the y-directional variables of each key.inputContainer.updateHeight()callsrequestLayout()on the View the holds the keyboard and its keys.inputContaineris a FrameLayout containing the keyboard view (among other things).
Why isn't the
requestLayoutcall sufficient to reposition the keyboard? How do I programmatically force the keyboard to be repositioned at the bottom of the screen? - Assistant
One possible solution to the issue could be to add a
OnLayoutChangeListenerto theinputContainerview in theonStartInputViewmethod. This listener will be called when the view layout changes, allowing for the keyboard to be repositioned properly.Here's an example of how this could be implemented:
java