Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Android中,如何在setText()中指定不同的文本样式?_Android_Textview_Settext - Fatal编程技术网

在Android中,如何在setText()中指定不同的文本样式?

在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); 您正在搜索以

我想创建一个setText,它派生一个textView,但包含不同textStyle的文本

例如,下面有一些代码,我询问如何在不处理xml文件的情况下在setText中使用不同的textStyle

    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);
因此,字体必须位于字体文件夹中