0

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?

Alex K
  • 22,315
  • 19
  • 108
  • 236
  • Do you want to change local setting on device for change font style? –  Sep 18 '12 at 07:06
  • check this may be helpful to you http://stackoverflow.com/questions/4395309/android-want-to-set-custom-fonts-for-whole-application-not-runtime – Vishal Pawar Sep 18 '12 at 07:08
  • @Manjunathab Why did you over and over again undo the changes and breaks the formatting? – Alex K Sep 18 '12 at 07:14
  • @AlexK just i was trying to format it properly – Manjunatha b Sep 18 '12 at 07:22
  • @Manjunathab Did you check the result of your editing? – Alex K Sep 18 '12 at 07:24
  • 1
    @Lokesh i want support entire application with custom font. without using phone settings – Manjunatha b Sep 18 '12 at 07:26
  • @AlexK hmmmmm i was not aware of that .... – Manjunatha b Sep 18 '12 at 07:30
  • For entire application, I think we have the chance with .ttf file. What's the problem wtih .ttf using typeface?? –  Sep 18 '12 at 07:56
  • @Lokesh if i have some 20 textviews in each activity(i have 9 activity screens) in application .. then i need set the typeface for each textview in each activity which is very tedious... thats y looking for other alternative solution which can set for entire application. – Manjunatha b Sep 18 '12 at 08:56
  • Yes, I understood.. But, its not an issue.. you just add like a property. For example: textcolor, text size , same as text font.Typeface font = Typeface.createFromAsset(getAssets(), "MARKER.TTF");Text1.setTypeface(font);Text2.setTypeface(font); –  Sep 18 '12 at 09:02
  • @Lokesh then if i have 20 textViews then i need to have Text1.setTypeface(font) repeated for 20 textViews in each activity. can't we have some global declaration which can used for through out entire apps. thanks – Manjunatha b Sep 18 '12 at 09:39
  • @Satya The link is very usefull... if i have to support for some 20 different languages then things will become very tedious. Any alternative way to achieve. thanks – Manjunatha b Sep 18 '12 at 09:57

0 Answers0