2012-03-30 46 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);