在Android中,如何在setText()中指定不同的文本样式?
我想创建一个setText,它派生一个textView,但包含不同textStyle的文本 例如,下面有一些代码,我询问如何在不处理xml文件的情况下在setText中使用不同的textStyle在Android中,如何在setText()中指定不同的文本样式?,android,textview,settext,Android,Textview,Settext,我想创建一个setText,它派生一个textView,但包含不同textStyle的文本 例如,下面有一些代码,我询问如何在不处理xml文件的情况下在setText中使用不同的textStyle TextView textView1 = (TextView) findViewById(R.id.textView1); textView1.setText("The sum of numbers 1 to " + lastNumber + " is "+ sum); 您正在搜索以
TextView textView1 = (TextView) findViewById(R.id.textView1);
textView1.setText("The sum of numbers 1 to " + lastNumber + " is "+ sum);
您正在搜索以下内容: 你也可以检查这个 或者,如果您只想设置一种字体,请使用以下选项:
Typeface font = Typeface.createFromAsset(activity.getAssets(),
fonts/androidnation.ttf");
TextView title .setTypeface(font);
因此,字体必须位于字体文件夹中