2012-03-30 83 views
0

我有一个包含textview的小部件布局。我想将marathi文本设置为该textview。 我正在尝试在屏幕上显示马拉蒂新闻的股票小部件。问题是我无法将marathi字体设置为remoteview。任何帮助?在此先感谢Android中Textview的Marathi字体支持

编辑:

这里是我的代码

RemoteViews remoteViews = new RemoteViews(this .getApplicationContext().getPackageName(), R.layout.widget_layout); 
// Set the text 
remoteViews.setTextViewText(R.id.txt_marqee, stringBuffer); 

,这是我的远程视窗充气widget_layout。这个布局包含我用作ticker的textview。我想将devnagari字体设置为remoteview。任何帮助?

+0

拉克什,如果你有主屏幕小部件然后自定义字体,不得使用在主屏幕中,请使用inbuild字体或为ImageView生成位图。 – 2012-03-30 09:47:03

回答

3

由于Android不支持梵文字体,所以仍然可以将该支持提供给您的应用程序。

对于Marathi字体复制字体文件到您的资产文件夹。然后使用下面的代码。

TextView text_view = new TextView(this); 
Typeface font = Typeface.createFromAsset(getAssets(), "MarathiFont.ttf"); 
text_view.setTypeface(font); 
text_view.setText("मराठी"); 

以同样的方式ü可以给印地文支持....

+0

RemoteViews remoteViews =新RemoteViews(这 \t \t \t \t \t .getApplicationContext()getPackageName(), \t \t \t \t \t R.layout.widget_layout。); \t \t \t //设置文本 \t \t \t remoteViews.setTextViewText(R.id。txt_marqee,stringBuffer);这是我的远程视图。我蚂蚁将devnagari字体设置为remoteview.Any帮助? – Rakesh 2012-03-30 09:30:21

+0

请在问题中添加代码......我无法在评论 – 2012-03-30 09:31:37

+0

中阅读它,因为Sajid Shaikh说您只能在您的流程中将您的字体渲染到 位图,然后将其推送到RemoteViews中。 – 2012-03-30 09:44:58

0

为此,您将获得一个MarathiFont.ttf文件,然后

Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/MarathiFont.ttf"); 

然后:

text.setTypeFace(tf); 
+0

从哪里我会得到这个MarathiFont.ttf ??? – 2012-09-13 05:14:09

+1

@ArindamMukherjee:从这里http://marathi.changathi.com/Fonts.aspx – Bhavin 2012-09-13 05:17:47

+0

谢谢u..i下载kirana.ttf文件..现在它正在工作..可以告诉我它如何在模拟器上工作??? – 2012-09-13 05:58:45

0

老兄其如此简单只需使用下面的代码行

TextView info=(TextView)findViewById(R.id.info); 
Typeface face=Typeface.createFromAsset(getAssets(), "fonts/georgia.ttf"); 
info.setTypeface(face); 

将您的字体放置在资产中的字体文件夹中。工作karel。谢谢

+0

RemoteViews remoteViews = new RemoteViews(this .getApplicationContext()。getPackageName(),R.layout.widget_layout); //设置文本remoteViews.setTextViewText(R.id.txt_marqee,stringBuffer);这是我的远程视图。我蚂蚁将devnagari字体设置为remoteview.Any帮助? – Rakesh 2012-03-30 09:31:43

+0

因为小部件存在于其他进程中,所以它们只能使用系统 字体,而不能使用您的 程序包内部的其他字体。解决这个问题的方法之一是将您的字体渲染到您的进程中的 位图,然后将其推送到RemoteViews中。 http://www.mailinglistarchive.com/html/[email protected]/2009-06/msg00211.html – 2012-03-30 09:36:45

0

首先,你应该在设备中添加马拉字体(ttf)。以下是用于添加字体的adb命令。

ADBス推.TTF /system/fonts/DroidSansFallback.ttf

然后使用此字体用于显示。

0

1)下载从网站马拉字体如下:

http://www.angelfire.com/pop/top4/fonts/

2)应用下面的代码:

TextView info=(TextView)findViewById(R.id.textview); 
Typeface face=Typeface.createFromAsset(getAssets(), "fonts/your font.ttf"); 
info.setTypeface(face);