2015-04-16 51 views
-4

我需要完整的細節設置各種樣式的字體以及在哪些文件夾中我們必須提及樣式和所有內容。如何爲文本視圖設置不同的字體樣式

像ProximoNova-Semibold.otf,ProximoNova-Regular.otf

+0

只需雙擊該OTF文件即可。點擊安裝。 –

回答

0

從互聯網上下載所需的字體,然後將其放置在資產/ fonts文件夾中。

您可以通過Typeface類在java代碼中訪問它。

TextView tx = (TextView)findViewById(R.id.textview1); 
Typeface custom_font = Typeface.createFromAsset(getAssets(), "fonts/font name.ttf"); 
tx.setTypeface(custom_font); 
+0

我已經試過上面的代碼,但它沒有解決 –

+0

你下載了正確的ttf文件嗎? 你是否用上述代碼片段中的「name.ttf」替換了文件的實際名稱? – includeMe

+0

txt1 =(TextView)findViewById(R.id.txt_Card_label); \t \t Typeface custom_font = Typeface.createFromAsset(getAssets(),「fonts/Roboto/ProximoNova-Regular.otf」); \t \t txt1.setTypeface(custom_font); */ –

0

您可以使用calligraphy庫,庫中有自定義選項。否則使用includeMe的代碼。

相關問題