Display all Unicode chars in TextView

Is there any way to show all Unicode chars in my TextView, on my phone?

I have tried special characters like 'u0279' and I get something like box (default char). Is this based on l10n and i18n settings?


tv=(TextView)findViewById(R.id.textView1);
Typeface font= Typeface.createFromAsset(getAssets(), "TAU_BHON.TTF");
tv.setTypeface(font); 

将支持您的语言的字体放置在资产文件夹中。在这种情况下,我使用了TAU_BHON.TTF


This usually happens because of the font used, the default one does not support/have implemented all unicode chars , you need to use a full featured font like DejaVuSans.ttf

@sakthi shows a sample that should work without problem, check if your android version supports it


Try this code:

String str = "u00F6";

System.out.println("new value-" + str);

You will get:

new value-ö

Here is a sample android project that i created to check the feature:

Java file:

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 File:

<?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>

Screen Shot:

链接地址: http://www.djcxy.com/p/96748.html

上一篇: 如何使用自定义背景图像制作按钮在Android中显示点击动画

下一篇: 在TextView中显示所有的Unicode字符