有沒有什麼方法可以在我的手機上顯示TextView中的所有Unicode字符?在TextView中顯示所有的Unicode字符
我嘗試過特殊字符,比如'\ u0279',我得到了一些像box(默認字符)的東西。 這是基於l10n和i18n設置嗎?
有沒有什麼方法可以在我的手機上顯示TextView中的所有Unicode字符?在TextView中顯示所有的Unicode字符
我嘗試過特殊字符,比如'\ u0279',我得到了一些像box(默認字符)的東西。 這是基於l10n和i18n設置嗎?
tv=(TextView)findViewById(R.id.textView1);
Typeface font= Typeface.createFromAsset(getAssets(), "TAU_BHON.TTF");
tv.setTypeface(font);
地方的字體,會支持你的語言在folder.In這種情況下,我已經使用TAU_BHON.TTF資產
試試這個代碼:
String str = "\u00F6";
System.out.println("new value-" + str);
您將獲得:
new value-ö
這是我創建的示例Android項目來檢查功能:
的Java文件:
package com.testd;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class Main extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String str = "\u00F6";
TextView tv = (TextView) findViewById(R.id.a);
tv.setText("sajklasdklfjasdf " + str);
}
}
XML文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="@+id/a" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/hello" />
</LinearLayout>
屏幕截圖:
這通常是因爲字體使用,默認的一個不支持/已經實現了所有的Unicode字符,你需要使用一個全功能的字體像DejaVuSans.ttf
@sakthi表明,應該沒有問題工作的樣本,請檢查您的Android版本支持
正如我所提到的,我得到錯誤java.lang.RuntimeException:無法啓動活動ComponentInfo {mypackage/mypackage.MyActivity}:java.lang.RuntimeException:本機字體無法制作 – zmeda 2011-05-19 10:58:31
rigth,但該示例說:字體font = Typeface.createFromAsset(getAssets(),「TAU_BHON.TTF」);嘗試,而不是隻getAssests()類似getContext()。getAssests(),也許是因爲無法獲得上下文 – yeradis 2011-05-19 11:30:13
我已成功從資產中加載字體,仍然我得到這個醜陋的框,而不是正確的字符。 – zmeda 2011-05-19 11:33:07
你是否在Strings.xml文件中添加這些字符? – mudit 2011-05-19 06:55:21
假設我想從(utf8)數字(例如0279)到(utf8)char'\ u0279'進行簡單的轉換。所以我有EditText用戶寫下數字和TextView,其中這些數字被轉換爲字符。通過按下按鈕轉換完成。 – zmeda 2011-05-19 07:02:38
爲此,您必須記錄各個符號的所有可用字符代碼。將它與記錄進行比較,然後顯示符號。 – mudit 2011-05-19 07:05:59