Spanner

class Spanner(text: CharSequence) : SpannableString

简化富文本上色,点击,加粗等功能的SpannableString.

Author

Ayvytr 's GitHub

Since

3.1.3

  1. 取消长按点击事件

  2. 修改点击时的字体自动换行问题

  3. 取消点击时的背景色圆角

  4. 修改点击时的字体颜色和背景色为TextColorSpanBgColorSpan保存

0.1.0

Constructors

Spanner
Link copied to clipboard
fun Spanner(text: CharSequence)

Types

Companion
Link copied to clipboard
object Companion

Functions

all
Link copied to clipboard
fun all(): Spanner
fun all(vararg targets: String): Spanner
allStartWith
Link copied to clipboard
fun allStartWith(vararg prefixs: String): Spanner
backgroundColor
Link copied to clipboard
@JvmOverloads
fun backgroundColor(bgColor: Int, pressedBgColor: Int = bgColor): Spanner

设置字体背景色和点击时的背景色

backgroundColorRes
Link copied to clipboard
@JvmOverloads
fun backgroundColorRes(@ColorRes bgColorRes: Int, @ColorRes pressedBgColorRes: Int = bgColorRes): Spanner
between
Link copied to clipboard
fun between(startText: String, endText: String): Spanner
bold
Link copied to clipboard
fun bold(): Spanner
boldItalic
Link copied to clipboard
fun boldItalic(): Spanner
chars
Link copied to clipboard
open fun chars(): IntStream
codePoints
Link copied to clipboard
open fun codePoints(): IntStream
equals
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
first
Link copied to clipboard
fun first(target: String): Spanner
font
Link copied to clipboard
fun font(font: String): Spanner
get
Link copied to clipboard
operator override fun get(p0: Int): Char
getChars
Link copied to clipboard
override fun getChars(p0: Int, p1: Int, p2: CharArray, p3: Int)
getSpanEnd
Link copied to clipboard
open override fun getSpanEnd(p0: Any): Int
getSpanFlags
Link copied to clipboard
open override fun getSpanFlags(p0: Any): Int
getSpans
Link copied to clipboard
open override fun <T : Any> getSpans(p0: Int, p1: Int, p2: Class<T>): Array<T>
getSpanStart
Link copied to clipboard
open override fun getSpanStart(p0: Any): Int
hashCode
Link copied to clipboard
open override fun hashCode(): Int
italic
Link copied to clipboard
fun italic(): Spanner
last
Link copied to clipboard
fun last(target: String): Spanner
nextSpanTransition
Link copied to clipboard
open override fun nextSpanTransition(p0: Int, p1: Int, p2: Class<Any>): Int
normal
Link copied to clipboard
fun normal(): Spanner
onClick
Link copied to clipboard
fun onClick(textView: TextView, action: (CharSequence, Range) -> Unit): Spanner
range
Link copied to clipboard
fun range(from: Int, to: Int): Spanner
ranges
Link copied to clipboard
fun ranges(ranges: List<Range>): Spanner
removeSpan
Link copied to clipboard
open override fun removeSpan(p0: Any)
scaleSize
Link copied to clipboard
fun scaleSize(proportion: Int): Spanner
setSpan
Link copied to clipboard
open override fun setSpan(p0: Any, p1: Int, p2: Int, p3: Int)
size
Link copied to clipboard
fun size(dp: Int): Spanner
strikethrough
Link copied to clipboard
fun strikethrough(): Spanner
subscript
Link copied to clipboard
fun subscript(): Spanner
subSequence
Link copied to clipboard
override fun subSequence(startIndex: Int, endIndex: Int): CharSequence
superscript
Link copied to clipboard
fun superscript(): Spanner
tag
Link copied to clipboard
fun tag(tag: Any): Spanner
tagOf
Link copied to clipboard
fun tagOf(range: Range): Any?
tags
Link copied to clipboard
fun tags(vararg tags: Any): Spanner
fun tags(tags: List<Any>): Spanner
textColor
Link copied to clipboard
@JvmOverloads
fun textColor(textColor: Int, pressedTextColor: Int = textColor): Spanner

设置字体颜色和点击时的字体颜色

textColorRes
Link copied to clipboard
@JvmOverloads
fun textColorRes(@ColorRes textColorRes: Int, @ColorRes pressedTextColorRes: Int = textColorRes): Spanner
toString
Link copied to clipboard
override fun toString(): String
underline
Link copied to clipboard
fun underline(): Spanner

Properties

length
Link copied to clipboard
override val length: Int