code_finder
code_finder

Reputation: 1370

How to create android UI in Hindi?

I am developing an app where it need to supported in two languages (English & Hindi). I am familiar in designing in English but i don't have any idea regarding how to create UI in Hindi.

Can anyone please help me how to create android UI in Hindi......? I want the following XML file in Hindi means in the place of Name & Password as per below image, i need to get Hindi words.. but i kept Hindi text means it is showing boxes in place of username & password. As you can find below button. created two dynamic textview. English text is displaying exactly but coming to Hindi text displaying boxes.

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layoutbase"    
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TableLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >
    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:layout_weight="1">
        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="30px"
            android:text="Username"/>
        <EditText
            android:id="@+id/editText1"
            android:layout_weight="1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
        </EditText>
    </TableRow>
    <TableRow
        android:id="@+id/tableRow2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1" >
          <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="30px"
            android:text="नमस्ते"/>
        <EditText
            android:id="@+id/editText2"
            android:layout_weight="1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
        </EditText>
    </TableRow>
</TableLayout>

output is displaying boxes as per below image

enter image description here enter image description here

Upvotes: 1

Views: 6207

Answers (5)

code_finder
code_finder

Reputation: 1370

solved the problem by myself. I have downloaded "mangal.ttf" (hindi font supported file) & copied it in fonts folder created in assets folder.

Modified my java code as

Main.java

    TextView tv1=new TextView(this);
    tv1.setTypeface(Typeface.createFromAsset(getAssets(),"fonts/mangal.ttf"));
    tv1.setText("इस अंग्रेज़ी हिन्दी अंग्रेज़ी शब्दकोश में आप आसानी से हिन्दी और अंग्रेज़ी शब्दों के अर्थ ढूंढ सकते हैं। नवम्बर ");
    tv1.setTextSize(20);
    layout.addView(tv1);

This worked for me.

Upvotes: 1

Dinesh
Dinesh

Reputation: 6532

You must download .ttf(true type font)file for hindi and create folder name as fonts in your project asset folder and paste hindi_font_file.ttf file in your asset under fonts folder and refer and set font face in your textview like below code:

Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/hindi_font_file.ttf");               
TextView tv = (TextView) findViewById(R.id.yourtextview);
tv.setTypeface(tf);
tv.setText("हिंदी");

Now hindi text display on your ui for more details try to follow instructions below post

Android Tamil font between english word

and here is link for download hindi ttf file

Upvotes: 1

curioustechizen
curioustechizen

Reputation: 10672

The static text that you display (Username, Password) etc need to be localized by supplying appropriate strings using Android's resources framework. Be aware about the platform version that you target. I don't recollect exactly what version of Android introduced Hindi support, but you can look it up in the release notes of each platform version.

Finally, if you want to accept user input in Hindi you again need to be aware of the platform version. You can go to Settings -> Language and Input; then the "Preferences" icon for Android Keyboard (AOSP) --> Input Languages. If you see Hindi in the list there, your platform should support Hindi input. However, I am not sure of device manufacturer support in this space so you should probably test on real devices.

Upvotes: 0

Aviral
Aviral

Reputation: 1141

Also, be aware that HTC does not support Hindi font display

Upvotes: 1

user370305
user370305

Reputation: 109257

Actually, what you need is Android-Localization, Which support both languages English and Hindi.

Look at this tutorial Android-Application-Localization.

Upvotes: 2

Related Questions