Jee*_*eva 4 layout fonts android textview typeface
这是我的泰米尔语html unicode字符串
முதல்பக்கக்திகள்
我正在使用此代码:
TextView text=(TextView)findViewById(R.id.text); // initialize to your textview
Typeface tf = Typeface.createFromAsset(this.getAssets(),"fonts/tamil.ttf");
text.setTypeface(tf);
text.setText("????? ???? ?????????");
Run Code Online (Sandbox Code Playgroud)
在Android中,这可能吗?
Jay*_*ayu 12
首先,您必须了解Android操作系统中没有泰米尔语语言支持(除了少数三星和SE手机),直到ICS(4.0).即便如此,它还有虫子,并且Jelly Bean(4.2)提供了全面的支持.
如果您在应用中使用Unicode Tamil字体,则只会看到框.原因是系统中没有泰米尔语字体.
这个解决方案有一个解决方案.您所要做的就是下载Bamini字体并将其放在您的资源文件夹中.并使用字体Bamini创建TypeFace并将其设置为TextView.
Typeface font1 = Typeface.createFromAsset(getAssets(), "fonts/Bamini.ttf");
customText1.setTypeface(font1);
Run Code Online (Sandbox Code Playgroud)
现在使用转换器将Unicode字体转换为Bamini编码.而不是Unicode文本提供转换后的Bamini编码脚本到setText
方法中.
如果您讨厌所有这些手动编码转换,请查看此库
正如我在上面所说,如果你想在运行应用程序时动态更改编码,那么考虑使用我为Android编写的库.该库将帮助您将Unicode字符串转换为Bamini,TSCII,TAB,TAM和Anjal.
设置很简单.您只需将库导入Android项目并调用库,如下所示.
// Initialise the Typeface (assumes TSCII, Bamini, Anjal, TAB or TAM font located inside assets/fonts folder)
Typeface tf = Typeface.createFromAsset(getAssets(),"fonts/mylai.ttf");
// Initialises the TextView
TextView tv = (TextView)findViewById(R.id.textView1);
//Setting the Typeface
tv.setTypeface(tf);
//Magic happens here ;) encoding conversion
String TSCIIString = TamilUtil.convertToTamil(TamilUtil.TSCII, "??????? ?????????");
//Setting the new string to TextView
tv.setText(TSCIIString);
Run Code Online (Sandbox Code Playgroud)
有一个示例应用程序以及库.查看应用程序如何使用库将Unicode字符串转换为Bamini,TAB,TAM,TSCII和Anjal.
请务必阅读本答案中关于如何在Android Native应用程序和WebViews上解决泰米尔问题的全面答案.
归档时间: |
|
查看次数: |
8047 次 |
最近记录: |