相关疑难解决方法(0)

是否可以在TextView中包含多个样式?

是否可以为TextView中的不同文本设置多个样式?

例如,我将文本设置如下:

tv.setText(line1 + "\n" + line2 + "\n" + word1 + "\t" + word2 + "\t" + word3);
Run Code Online (Sandbox Code Playgroud)

是否可以为每个文本元素设置不同的样式?例如,line1粗体,word1斜体等.

开发人员指南的常见任务和Android中的操作方法包括选择,突出显示或设置部分文本样式:

// Get our EditText object.
EditText vw = (EditText)findViewById(R.id.text);

// Set the EditText's text.
vw.setText("Italic, highlighted, bold.");

// If this were just a TextView, we could do:
// vw.setText("Italic, highlighted, bold.", TextView.BufferType.SPANNABLE);
// to force it to use Spannable storage so styles can be attached.
// Or we could specify that in the XML.

// …
Run Code Online (Sandbox Code Playgroud)

android styles textview

532
推荐指数
12
解决办法
26万
查看次数

标签 统计

android ×1

styles ×1

textview ×1