2012-07-13 52 views
1

我正在開發一個應用程序,它需要兩種語言的支持(英語&北印度語)。我對英語設計很熟悉,但對於如何在印地語中創建用戶界面我沒有任何想法。如何在印地語中創建android用戶界面?

任何人都可以請幫助我如何創建android用戶界面在印地文......? 我想用以下的XML文件在印地文的意思是在名稱&密碼按照下面的圖像,我需要得到印地文單詞..但我保留印地文文本意味着它是顯示框代替用戶名&密碼。正如你可以在下面找到按鈕。創建了兩個動態文本視圖。英文文本正在顯示,但會顯示北印度文字顯示框。

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> 

輸出顯示盒按如下圖

enter image description here enter image description here

+0

你需要針對Android 2.3及更高版本。那麼印地文字體應該可以訪問。 – Cheesebaron 2012-07-13 07:39:54

+0

雅,我使用2.3,但不知道如何顯示印地文字體。 – 2012-07-13 07:40:40

+0

根據這個錯誤報告,它不適用於每個2.3設備:https://code.google.com/p/android/issues/detail?id=4153它應該與ICS一起工作。這個線程描述瞭如何在你的應用中使用你自己的字體:http://stackoverflow.com/questions/4395309/android-want-to-set-custom-fonts-for-whole-application-not-runtime – Cheesebaron 2012-07-13 07:48:17

回答

1

您必須爲hindi下載.ttf(真實字體)文件,並在您的項目資產文件夾中創建文件夾名稱作爲字體,並在您的資產中將hindi_font_file.ttf文件粘貼到字體文件夾中,然後在您的文本視圖中引用和設置字體下面的代碼:

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

現在,印地文文本顯示在您的UI更多細節儘量按照以下指示後

Android Tamil font between english word

,這裏是link下載印地文ttf文件

+0

這是創建動態視圖的時候。有沒有什麼辦法如何從我們的XML文件顯示印地文視圖,因爲我想創建我的用戶界面在XML中,而不是動態的用戶界面... – 2012-07-13 07:54:18

+0

我用mangal.ttf文件。它也有效...... – 2012-07-13 07:56:17

+0

@code_finder應用你的TextView像TextView tv =(TextView)findViewById(R.id.your_textview_id_from_xml);! – Dinesh 2012-07-13 07:57:11

2

其實,你需要的是Android-Localization,支持兩種語言英語和印地文。

看看本教程Android-Application-Localization

+0

沒有使用本地化我需要運行它。基於用戶的選擇,如果他選擇印地文版意味着所有的應用程序需要在印地文中可見。這是主要標準。 – 2012-07-13 07:26:41

1

而且,要知道,HTC不支持印地文字體顯示

0

你顯示(用戶名,密碼)的靜態文本等需要使用Android的資源框架提供適當的字符串進行本地化。瞭解您定位的平臺版本。我不記得Android的版本是否引入了印地語支持,但是您可以在每個平臺版本的發行說明中查看它。

最後,如果您想接受用戶在印地語中的輸入,則需要了解平臺版本。你可以去設置 - >語言和輸入;然後Android鍵盤(AOSP)的「首選項」圖標 - >輸入語言。如果您在列表中看到印地語,您的平臺應支持印地語輸入。但是,我不確定設備製造商是否支持此空間,因此您應該在真實設備上進行測試。

+0

我想android會給2.3版本提供hindi支持。 – 2012-07-13 07:55:28

1

自己解決了這個問題。我已經下載「mangal.ttf」(hindi字體支持的文件)&將它複製到資產文件夾中創建的字體文件夾中。

修改了Java代碼

Main.java

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

這爲我工作。

+0

發佈後續問題的新問題。 – ThiefMaster 2012-07-14 10:06:16

相關問題