Android KeyboardView doesn't resize when rotated

I have a custom keyboard for my application, and I can not get it to resize when the device rotates. You can see what I mean here: http://imgur.com/TsEM9 and here: http://imgur.com/2hhX8

In my activity, I'm trying to get the keyboard to redraw like this:

@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if(mKeyboardView != null) mKeyboardView.invalidateAllKeys(); } 

I also tried calling invalidate (), but to no avail.

+4
source share
1 answer

Finally found the answer! I don't know if this is correct, but it seems to work. I had to recreate the keyboard while rotating, for example:

 @Override public void onConfigurationChanged (Configuration newConfig) { super.onConfigurationChanged(newConfig); createKeyboard(); } private void createKeyboard() { mKeyboard = new Keyboard(this, R.xml.qwerty); mKeyboardView = (MyKeyboardView) findViewById(R.id.keyboard_view); mKeyboardView.setKeyboard(mKeyboard); mKeyboardView.setOnKeyboardActionListener(new MyKeyboardActionListener((Activity)this)); } 

Moreover, for the record it was not that the view was not changed; It was. The problem was that the keys were not changed.

+4
source

Source: https://habr.com/ru/post/1399550/


All Articles