Anksmonani
Anksmonani

Reputation: 75

Android Layout Multicolor

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

Upvotes: 1

Views: 310

Answers (5)

Abdul Rahman Majeed
Abdul Rahman Majeed

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

MohK
MohK

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. enter image description here

Android will do the next magic automatically based on locale.

Upvotes: 0

Jai
Jai

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

Farouk Touzi
Farouk Touzi

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

acostela
acostela

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

Related Questions