Reputation: 75
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 Advance
Upvotes: 1
Views: 310
Reputation: 1135
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
Upvotes: 1
Reputation: 1933
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.
Android will do the next magic automatically based on locale.
Upvotes: 0
Reputation: 486
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
Upvotes: 1
Reputation: 3456
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.
Upvotes: 1
Reputation: 2727
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.
Upvotes: 1