Thursday 15 August 2013

Android Localization Demo

Demo:

1)MainActivity.java: 
package com.venky.androidlocalizationdemo;
import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends Activity {

      @Override
      protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);

            TextView tvEnglish = (TextView) findViewById(R.id.tvEnglish);
            TextView tvTelugu = (TextView) findViewById(R.id.tvTelugu);
            TextView tvHindi = (TextView) findViewById(R.id.tvHindi);
            TextView tvTamil = (TextView) findViewById(R.id.tvTamil);
            TextView tvKannada = (TextView) findViewById(R.id.tvKannada);
            TextView tvMalayalam = (TextView) findViewById(R.id.tvMalayalam);

            Typeface face = Typeface.createFromAsset(getAssets(),
                        "akshar.ttf");
            tvEnglish.setTypeface(face);
            tvTelugu.setTypeface(face);
            tvHindi.setTypeface(face);
            tvTamil.setTypeface(face);
            tvKannada.setTypeface(face);
            tvMalayalam.setTypeface(face);

            tvEnglish.setText("Welcome");
            tvTelugu.setText("సుస్వాగతము");
            tvHindi.setText("आपका स्वागत है");
            tvTamil.setText("நல்வரவு");
            tvKannada.setText("ಸ್ವಾಗತ");
            tvMalayalam.setText("വെല്കം ");

      }
}


2)main.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#5F04B4"
    android:orientation="vertical" >

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/tvEnglish"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:gravity="center"
                android:textColor="#ffffff"
                android:textSize="18dp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/tvTelugu"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:gravity="center"
                android:textColor="#ffffff"
                android:textSize="18dp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/tvHindi"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:gravity="center"
                android:textColor="#ffffff"
                android:textSize="18dp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/tvTamil"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:gravity="center"
                android:textColor="#ffffff"
                android:textSize="18dp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/tvKannada"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:gravity="center"
                android:textColor="#ffffff"
                android:textSize="18dp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/tvMalayalam"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:gravity="center"
                android:textColor="#ffffff"
                android:textSize="18dp"
                android:textStyle="bold" />
        </LinearLayout>
    </ScrollView>

</LinearLayout>


3)Download ttf file:
Download ttf file and put into assets folder
Download Here 

4)Download this Project Click Here

1 comment:

  1. Android localization can be managed easily with the translation and localization platform https://poeditor.com/

    ReplyDelete