我需要帮助,我陷入了困境。我的要求是,我需要在工具提示中添加文本。我实际上是这样做的。但是文本包括多行文本,还有一些行具有粗体样式,而另一些行具有常规样式和自定义字体样式。通过我正在使用的以下代码,我可以添加粗体、斜体和常规样式。但我需要在文本中添加以下自定义字体样式。请查看我的以下代码。
textViewToShow.setOnClickListener { view ->
val tfBold = Typeface.createFromAsset(
context!!.assets,
"fonts/myriad_pro_bold.ttf"
)
val tfRegular = Typeface.createFromAsset(
context!!.assets,
"fonts/myriad_pro_regular.ttf"
)
var string1 = “Item show in Bold style”
var string2 = “Item show in Regular style”
var string3 = “Item show in Regular style with item description”
val holesTextView = Html.fromHtml("<b>" + string1 + "</b> <br><br> <b><i>"+ string2 + "</i></b> " + string3)
showToolTip(view, holesTextView)
}
private fun showToolTip(view: View, holesTextView: Spanned) {
val builder: Tooltip.Builder =
Tooltip.Builder(view, R.style.Tooltip)
.setText(holesTextView)
builder.show()
}
非常感谢任何解决方案/建议