我想在我的应用程序中将字体设置为一个文本视图。 我使用它如下,它工作正常:
Typeface font = Typeface.createFromAsset( getAssets(), "fontawesome/fonts/fontawesome-webfont.ttf" );
TextView awesomeButton = (TextView)findViewById(R.id.awesome_button);
awesomeButton.setTypeface(font);
awesomeButton.setText(MainActivity.this.getString(R.string.heart));
但是当我想像鳕鱼一样使用它时,它不起作用:
Typeface font = Typeface.createFromAsset( getAssets(), "fontawesome/fonts/fontawesome-webfont.ttf" );
TextView awesomeButton = (TextView)findViewById(R.id.awesome_button);
awesomeButton.setTypeface(font);
awesomeButton.setText("");
答案 0 :(得分:1)
试试这个
Typeface font = Typeface.createFromAsset( getAssets(), "fontawesome/fonts/fontawesome-webfont.ttf" );
TextView awesomeButton = (TextView)findViewById(R.id.awesome_button);
awesomeButton.setTypeface(font);
awesomeButton.setText(Html.fromHtml(""));
答案 1 :(得分:0)
您可以尝试使用以下代码
awesomeButton.setText(Html.fromHtml(""));
答案 2 :(得分:0)
你可以试试这段代码,我觉得这个可以帮助你。
Typeface font = Typeface.createFromAsset( getAssets(), "fontawesome/fonts/fontawesome-webfont.ttf" );
TextView awesomeButton = (TextView)findViewById(R.id.awesome_button);
awesomeButton.setTypeface(font);
String tmpHtml = "<html>♥</html>";
String htmlTextStr = Html.fromHtml(tmpHtml).toString();
awesomeButton.setText(htmlTextStr);