I am aware of Creating a new values directory for the language with the suffix of the language code. For German: values-de or French: values-fr then copy our string.xml into that and translate each entry. And this works based on the Phone Localization settings
I know that , we can bypass the phone setting and and make the user select his required language inside the app using below code.
Locale appLoc = new Locale("en");
Locale.setDefault(appLoc);
Configuration appConfig = new Configuration();
appConfig.locale = appLoc;
getBaseContext().getResources().updateConfiguration(appConfig, getBaseContext().getResources().getDisplayMetrics());
I have give a language selection option inside my app, and make the user select the language he wants for the app.. dynamically switch between the string.xml (for different languages).
My question is ... is language option provide inside app should be support by phone compulsory? Because, consider that my phone don't have support for Kannada regional language and if user selects Kannada as language option in my app. The values are displayed as [][][][] (boxes). How set font support also for entire application?
I don't want use typeface for on each and every view in android as below
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/comicsans.ttf");
for(int i = 0; i <root.getChildCount(); i++) {
View v = root.getChildAt(i);
if(v instanceof TextView ) {
((TextView)v).setTypeface(tf);
} else if(v instanceof Button) {
((Button)v).setTypeface(tf);
} else if(v instanceof EditText) {
((EditText)v).setTypeface(tf);
} else if(v instanceof ViewGroup) {
changeFonts((ViewGroup)v);
}
}
Can we use some local setting to configure the font for entire application?