Package com.itxca.spannablex

Types

Link copied to clipboard
data class ReplaceRule(replaceString: String, isRegex: Boolean, matchRange: IntRange?, newString: CharSequence?, replacementMatch: OnSpanReplacementMatch?)

替换规则

Link copied to clipboard
class Span

Chain Spannable

sample:

TextView.setText(Span.create()
.text("this is real text.")
.text("spannable").color(Color.BLUE).style(Typeface.BOLD)
.spannable())
Link copied to clipboard
class SpanDsl

DSL Spannable

Functions

Link copied to clipboard
fun Activity.activateAllTextViewClick(background: Boolean = true, @IdRes vararg ignoreId: Int)

循环 Activity 控件并配置 LinkMovementMethodClickableMovementMethod

fun Fragment.activateAllTextViewClick(background: Boolean = true, @IdRes vararg ignoreId: Int)

循环 Fragment 控件并配置 LinkMovementMethodClickableMovementMethod

fun ViewBinding.activateAllTextViewClick(background: Boolean = true, @IdRes vararg ignoreId: Int)

循环 ViewBinding 控件并配置 LinkMovementMethodClickableMovementMethod

Link copied to clipboard
fun TextView.activateClick(background: Boolean = true): TextView

配置 LinkMovementMethodClickableMovementMethod

Link copied to clipboard
fun View?.autoActivateClick(background: Boolean, @IdRes vararg ignoreId: Int)

循环获取控件并配置 LinkMovementMethodClickableMovementMethod

Link copied to clipboard
operator fun Spanned.plus(other: CharSequence): SpannableStringBuilder

扩展Spanned +, 保留样式 operator Spannable + CharSequence

Link copied to clipboard
fun CharSequence.removeAllSpans(): CharSequence

删除所有CharacterStyle Span

Link copied to clipboard
inline fun <T> CharSequence.removeSpans(): CharSequence

删除指定Span

Link copied to clipboard
fun Any?.spannable(builderAction: SpanDsl.() -> Unit): SpannableStringBuilder

构建Spannable

Link copied to clipboard
fun String.toReplaceRule(isRegex: Boolean = false, matchIndex: Int? = null, matchRange: IntRange? = null, newString: CharSequence? = null, replacementMatch: OnSpanReplacementMatch? = null): ReplaceRule

创建替换规则

Properties

Link copied to clipboard
val String.span: SpannedString

String 转为 Spannable, 以便进行plus操作