How to change Android Keyboard language?
I have set below code to set language. I set different language from Settings and trying to set English language.
Locale.setDefault(Locale.ENGLISH);
Configuration config = getResources().getConfiguration();
config.locale = Locale.ENGLISH;
getBaseContext().getResources().updateConfiguration(config, null);
Keyboard shortcut: To switch between keyboard layouts, press Alt+Shift. Note: The icon is just an example; it shows that English is the language of the active keyboard layout. The actual icon shown on your computer depends on the language of the active keyboard layout and version of Windows.
Changing locale
only changes the resources
(e.g., strings, images, etc) to those defined for a specific locale
in an app. To change the language supported by the keyboard
, you have to make sure a proper input method
is installed on the device
(because the input method itself is also an app, it will change to a corresponding language).
For example, there is only English keyboard on Nexus S
, if I need a keyboard that supports other language, I need to find a input method
that supports that language, and install it.
To make sure the user have one, you can make some alert to take the users' attention, or bring them to the keyboard settings activity by ACTION_XXX_SETTINGS
intent.
(API 24+): If you are using a TextView
/EditText
, then you can call TextView#setImeHintLocales(LocaleList)
textView.setImeHintLocales(new LocaleList(new Locale("zh", "CN")));
Note: This works on very few keyboards (at the time of writing, GBoard works and SwiftKey doesn't).
Note: If you want new "hint" to take effect immediately you need to call InputMethodManager#restartInput(View)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With