Span Dsl
DSL Spannable
sample: ```kotlin TextView.text = spannable { "this is real text.".text() "spannable".color(Color.BLUE).style(Typeface.BOLD) }
Content copied to clipboard
Types
Functions
Link copied to clipboard
fun Any?.absoluteSize(size: Int, dp: Boolean = true, replaceRule: Any? = null)
Content copied to clipboard
AbsoluteSizeSpan 设置文本绝对大小
Link copied to clipboard
BackgroundColorSpan 背景颜色
Link copied to clipboard
Link copied to clipboard
fun Any?.clickable(@ColorInt color: Int? = null, @ColorInt backgroundColor: Int? = null, style: Int? = null, config: SimpleClickableConfig? = null, replaceRule: Any? = null, onClick: OnSpanClickListener? = null)
Content copied to clipboard
SimpleClickableSpan 设置文本点击效果
Link copied to clipboard
fun Any?.glide(view: TextView, url: Any, useTextViewSize: TextView? = null, size: DrawableSize? = null, @Px marginLeft: Int? = null, @Px marginRight: Int? = null, align: GlideImageSpan.Align = GlideImageSpan.Align.CENTER, loopCount: Int? = null, requestOption: RequestOptions? = null, replaceRule: Any? = null)
Content copied to clipboard
GlideImageSpan 图片
Link copied to clipboard
fun Any?.image(context: Context, bitmap: Bitmap, useTextViewSize: TextView? = null, size: DrawableSize? = null, @Px marginLeft: Int? = null, @Px marginRight: Int? = null, align: CenterImageSpan.Align = CenterImageSpan.Align.CENTER, replaceRule: Any? = null)
Content copied to clipboard
fun Any?.image(context: Context, uri: Uri, useTextViewSize: TextView? = null, size: DrawableSize? = null, @Px marginLeft: Int? = null, @Px marginRight: Int? = null, align: CenterImageSpan.Align = CenterImageSpan.Align.CENTER, replaceRule: Any? = null)
Content copied to clipboard
fun Any?.image(context: Context, @DrawableRes resourceId: Int, useTextViewSize: TextView? = null, size: DrawableSize? = null, @Px marginLeft: Int? = null, @Px marginRight: Int? = null, align: CenterImageSpan.Align = CenterImageSpan.Align.CENTER, replaceRule: Any? = null)
Content copied to clipboard
fun Any?.image(drawable: Drawable, source: String? = null, useTextViewSize: TextView? = null, size: DrawableSize? = null, @Px marginLeft: Int? = null, @Px marginRight: Int? = null, align: CenterImageSpan.Align = CenterImageSpan.Align.CENTER, replaceRule: Any? = null)
Content copied to clipboard
CenterImageSpan 图片
Link copied to clipboard
fun Any?.imageParagraph(bitmap: Bitmap, @Px padding: Int = 0, useTextViewSize: TextView? = null, size: DrawableSize? = null)
Content copied to clipboard
ParagraphBitmapSpan 设置段落图片
fun Any?.imageParagraph(drawable: Drawable, @Px padding: Int = 0, useTextViewSize: TextView? = null, size: DrawableSize? = null)
Content copied to clipboard
ParagraphDrawableSpan 设置段落图片
Link copied to clipboard
fun Any?.leadingMargin(@IntRange(from = 1 ) firstLines: Int, @Px firstMargin: Int, @Px restMargin: Int = 0)
Content copied to clipboard
LeadingMarginSpan 设置段落文本缩进
Link copied to clipboard
LineBackgroundSpan 设置段落背景颜色
Link copied to clipboard
LineHeightSpan 设置段落行高
Link copied to clipboard
MaskFilterSpan 设置文本蒙版效果
Link copied to clipboard
fun Any?.quote(@ColorInt color: Int, @Px @IntRange(from = 0 ) stripeWidth: Int = 10, @Px @IntRange(from = 0 ) gapWidth: Int = 0)
Content copied to clipboard
fun Any?.quote(colorString: String, @IntRange(from = 0 ) stripeWidth: Int = 10, @IntRange(from = 0 ) gapWidth: Int = 0)
Content copied to clipboard
QuoteSpan 设置段落引用样式(段落前竖线标识)
Link copied to clipboard
fun Any?.relativeSize(@FloatRange(from = 0.0 ) proportion: Float, replaceRule: Any? = null)
Content copied to clipboard
RelativeSizeSpan 设置文本相对大小
Link copied to clipboard
StrikethroughSpan 设置文本删除线
Link copied to clipboard
fun Any?.suggestion(context: Context, suggestions: Array<String>, flags: Int = SuggestionSpan.FLAG_EASY_CORRECT or SuggestionSpan.FLAG_AUTO_CORRECTION, locale: Locale? = null, notificationTargetClass: Class<*>? = null, replaceRule: Any? = null)
Content copied to clipboard
SuggestionSpan 设置文本输入提示
Link copied to clipboard
SuperscriptSpan 设置文本为上标
Link copied to clipboard
fun Any?.textAppearance(style: Int = Typeface.NORMAL, @Px size: Int = -1, @ColorInt color: Int? = null, family: String? = null, linkColor: ColorStateList? = null, replaceRule: Any? = null)
Content copied to clipboard
TextAppearanceSpan 设置字体效果spanTypeface