1

i am currently working on one Android Application and i have to set layout according to country like if application is for Korea layout color must be blue and for india layout color must be red.

So how can i achieve that?

i know about multiple language values-kr // for Korea values //for English values-fr // for french

but for layout i don't know.

Help Me.

Thanks in Advanceenter image description here

Anksmonani
  • 75
  • 7
  • 1
    You can create a Style for each values folder with the colors which you would like to use, and then use it into your layout – programmer23 Feb 23 '15 at 10:38
  • For Korean, it should be **values-ko_rKR** or **values-ko**, not values-kr. Or **layout-ko_rKR** or **layout-ko**, not layout-kr. – Stephan Branczyk Feb 23 '15 at 10:53

5 Answers5

1

You can create a Style for each Values or in java code programming you can use a simple if statement that detects your location inside "oncreate method" and setbackground layout according to what you want using a drawable.

acostela
  • 2,597
  • 3
  • 33
  • 50
1

You have to determine your system language. You can use

Locale.getDefault().getLanguage();

to get the usual language code (e.g. "de", "en").

Then, create a base Activity for your app and override onCreate to set the theme according to your system language. Derive all your other activities from this base Activity. Check this tutorial.

Farouk Touzi
  • 3,451
  • 2
  • 19
  • 25
1

follow type of languages

res/values/strings.xml
Contains English text for all the strings that the application uses,
including text for a string named title.
res/values-fr/strings.xml
Contain French text for all the strings, including title.
res/values-ja/strings.xml
Contain Japanese text for all the strings except title.

How to display Korean Words in android app

Community
  • 1
  • 1
Jai
  • 486
  • 1
  • 8
  • 21
1

You may use this piece of code:

TelephonyManager tm = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);

String locale = tm.getSimCountryIso();

and choose:

 if (locale.equals(pk)) 
 { 
    view = inflater.inflate(R.layout.hazel_quick_form, container, false);
 } //fragment
iEngineer
  • 1,319
  • 1
  • 11
  • 27
Abdul Rahman Majeed
  • 1,125
  • 2
  • 10
  • 22
0

Take example of TextView.

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world"
        android:textColor="@color/textcolor" />

you can have colors.xml file in different locale folders like values , values-fr etc.

In example textview @color/textcolor can be defined with those saperated colors.xml files with different colors for different locales.

look at this. enter image description here

Android will do the next magic automatically based on locale.

MohK
  • 1,873
  • 1
  • 18
  • 29