Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Android KeyBoard language

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);
like image 925
Nishant Shah Avatar asked Apr 19 '11 10:04

Nishant Shah


People also ask

How do I switch between language keyboards?

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.


2 Answers

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.

like image 146
shihpeng Avatar answered Oct 12 '22 18:10

shihpeng


(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).

like image 45
DA_123 Avatar answered Oct 12 '22 18:10

DA_123