0

I have my default drawables (in english) and in addition for norwegian (nb) and german (de). My question is:

Is it possible if the localization is swedish (sv) or danish (da), instead of the normal behaviour to use the default drawables (in my case english), to use the norwegian drawables without copying the files from drawable-nb to darawable-sv and drawable-da?

Thank you in advance for your interest in answering my question.

2 Answers2

1

If you want the platform to pickup the relevant drawables depending on the locale, they have to be put in the appropriate locale folder - which is drawable-da and drawable-sv in your case.

You can use the Locale class and pick up drawables at runtime programmatically too.

Rajdeep Dua
  • 11,190
  • 2
  • 32
  • 22
1

Extracted from this answer, you can extend the Application class and set the locale to whatever you want:

public class MyApplication extends Application
{
    private Locale locale = null;

    @Override
    public void onCreate()
    {
        super.onCreate();

        Configuration config = getBaseContext().getResources().getConfiguration();

        String lang = config.locale.getLanguage();
        if (lang.equals("sv") || lang.equals("da"))
        {
            locale = new Locale("nb-NO");
            Locale.setDefault(locale);
            config.locale = locale;
            getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
        }
    }
}
Community
  • 1
  • 1
SERPRO
  • 10,015
  • 8
  • 46
  • 63
  • I had to add in the manifest file (also use at least API Level 4) and override onConfigurationChanged like in the link you gave. Also I had to change the ScaleType.CENTER_INSIDE to ScaleType.FIT_CENTER for my ImageSwithcers. – Mihai Popescu Dec 13 '11 at 15:21
  • @MihaiPopescu that is not related with the locale, is it? anyway, I'm glad I could help : – SERPRO Dec 13 '11 at 15:26
  • Changing the ScaleType is related to changing from API Level 3 to API Level 4, indeed. The reset are though. Adding anyDensity="true" is required else all the design elements 'shrink' and if you don't override onConfigurationChanged the locale will revert back to initial status. Thank you, SeRPRo. – Mihai Popescu Dec 13 '11 at 17:15