Click here to Skip to main content
12,998,028 members (58,049 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


13 bookmarked
Posted 15 Apr 2010

Force Locale on Android

, 29 Sep 2010
Rate this:
Please Sign up or sign in to vote.
While playing with localization on the Android for my app I came upon an annoying bug.It seems running on Motorola Milestone the fonts were getting smaller on each locale update.I use the following code for locale changing (from

While playing with localization on the Android for my app I came upon an annoying bug. It seems running on Motorola Milestone the fonts were getting smaller on each locale update.

I use the following code for locale changing (from

String languageToLoad  = "de";
Locale locale = new Locale(languageToLoad);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config, null);

Also in the AndroidManifest.xml I have (without this entry you get "Something wrong here, didn't expect "mypackagename" to be resumed"):


Here is how my screen should look like:

And here is how it was looking on Motorola Milestone.

After changing the Locale from Preferences the fonts keep gettting smaller and smaller

This was very annoying. I did not know exactly why this was happening. So I decided to reproduce the Milestone in the emulator. I got the specifications of the Milestone from the web and created in Eclipse an AVD with a resolution of 480x854 and density of 240.

After that I was able to reproduce the bug. It seems the density was the issue here. I searched for Android density and after some tries I found the solution. It seems I needed to have this in the AndroidManifest.xml


The most important is the android:anyDensity =" true ". After this, the application was shown correctly even on the Motorola Milestone.  

I hope this will be of help and don't forget to check out my enhanced logcat tool here

Edit: please read the comments of the article on my blog, you may find solutions to some of your localization problems - e.g. changing orientation resets locale, etc.

Edit 2: people have reported that sometimes the location resets to system default. Please read my post here: locale change does not affect menu  


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Adrian Vintu
Austria Austria
Adrian is an old timer who has had the wonderful experience of working in a variety of quality environments and with various quality people.

Throughout time he has got down with Assembler, C++, Borland Delphi, Java, C#, Android etc.
He took part in projects concerning software security, industrial controllers, health-food and health-care ERPS, AI simulations, data mining and mobile development.

Adrian is always interested in the big picture of the things and wishes to become a great architect one day.

Adrian maintains a blog here[^] and is trying to make it as nice and helpful and user friendly as possible.

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
Alex Manolescu1-Jan-11 10:31
memberAlex Manolescu1-Jan-11 10:31 
GeneralRe: My vote of 5 Pin
Adrian Vintu27-Mar-11 7:22
memberAdrian Vintu27-Mar-11 7:22 
GeneralThis should help a few apps Pin
SohjSolwin20-Apr-10 2:41
memberSohjSolwin20-Apr-10 2:41 
GeneralRe: This should help a few apps Pin
Adrian Vintu20-Apr-10 2:52
memberAdrian Vintu20-Apr-10 2:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170622.1 | Last Updated 29 Sep 2010
Article Copyright 2010 by Adrian Vintu
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid