如何显示在Android应用程序僧伽罗语统一code字 [英] How to display Sinhala Unicode characters in android app

查看:466
本文介绍了如何显示在Android应用程序僧伽罗语统一code字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I,M试图证明在Android应用程序僧伽罗语统一code字符。 当我使用三星的选项卡或手机单向$ C $,C是运行它没有问题。但它不会对其他手机工作或tab.cause没有僧伽罗语统一code.How做到这一点的一个例子,我运行在三星成功标签此code。

I,m trying to show Sinhala Unicode characters in android app. when i am using Samsung tabs or phones Unicode is running it on without problem.but it does not work on other phones or tab.cause there is no Sinhala Unicode.How to do this for an example i run this code on Samsung tab successfully.

Toast.makeText(this, "අන්තර්ජාල සම්බන්දතාවය තිබේ ", Toast.LENGTH_SHORT).show();

但其他手机或选项卡不能正常工作。

but other phones or tab does n't work.

推荐答案

您可能需要有一个僧伽罗人的字体文件(例如,Sinhalese.ttf)在目录资产/字体在你的项目的根目录。您创建一个虚拟的文本视图,因为它有一个名为方法 setTypeface ,其中设置字体的下一个code:

You might need to have a Sinhalese font file (say, Sinhalese.ttf) in the directory assets/fonts in the root of your project. You create a dummy text view because it has a method called setTypeface, which sets the font for next code:

import android.graphics.Typeface;

public class FontSampler extends Activity {
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);

    TextView tv=(TextView)findViewById(R.id.custom);  // a dummy text view
    Typeface face=Typeface.createFromAsset(getAssets(),
                                      "fonts/Sinhalese.ttf");
    tv.setTypeface(face);

    Toast.setView(tv).makeText(this, "අන්තර්ජාල සම්බන්දතාවය තිබේ ", Toast.LENGTH_SHORT).show();
  }
}

这样一来,即使没有安装Android手机的字体,然后嵌入在应用程序中的字体将成为。希望这可以帮助。

This way, even if an android phone doesn't have a font installed, then the font embedded in your app will serve. Hope this helps.

这篇关于如何显示在Android应用程序僧伽罗语统一code字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆