2013-09-26 51 views
2

我試圖在m TextView中呈現希伯來文字。android TextView不顯示希伯來語字體

我已閱讀here我需要將字體從默認的android改爲支持hebrew的字體。

我已經試過幾個解決方案,但他們沒有工作:

Typeface font= Typeface.createFromAsset(mContext.getAssets(), "fonts/Raanana.ttf"); 
    titleTextView.setTypeface(font); 

    titleTextView.setText(mTitles[position]); 

或:

titleTextView.setText(Html.fromHtml(mTitles[position])); 

這裏是我的xml:

<ImageView 
    android:id="@+id/todo_row_image" 
    android:layout_width="50dp" 
    android:layout_height="30dp" 
    android:layout_marginBottom="32dp" 
    android:layout_marginLeft="21dp" 
    android:contentDescription="my image" /> 

<TextView 
    android:id="@+id/todo_row_title" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="6dp" 
    android:lines="1" 
    android:text="@+id/titleTextView" 
    android:layout_toRightOf="@id/todo_row_image" 
    android:textSize="12sp" > 
</TextView> 

<TextView 
    android:id="@+id/todo_row_date" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/todo_row_title" 
    android:layout_marginTop="6dp" 
    android:lines="1" 
    android:text="@+id/dateTextView" 
    android:textSize="12sp" > 

</TextView> 

任何想法如何解決這個問題?

有沒有一種方法來定義每個應用程序的默認字體?每個佈局?

+2

希伯來語一個TextView效果很好「開箱的」。也許有BIDI的問題,但通常它顯示它很好。 – Sean

+0

就是這樣!我已經添加了我的xml。我該如何解決這個問題:圖像和兩行文字的權利:標題,日期? –

回答

0

TextView中的希伯來語很適合「開箱即用」。也許有BIDI的問題,但通常它顯示它很好。

關於你的第二個問題,你怎麼能建立一個佈局中使用希伯來語使用時,看看這個: RTL Languages support in android and resource qualifiers

+0

如果我的某些項目的文字是英文和希伯來文中的某些文字,你會建議什麼?我將如何確定書寫方向? –

+0

Android將檢查文本中的第一個字符,並根據字符語言確定方向。如果TextView沒有設置文本重力 - 你會自動看到效果。 – Sean

+0

肖恩,你是什麼意思「BIDI的問題」? @EladBenda你是如何解決它的?謝謝 – bentzy