@@ -14,6 +14,7 @@ import android.text.method.LinkMovementMethod
1414import android.text.style.*
1515import android.view.View
1616import android.widget.TextView
17+ import androidx.annotation.ColorInt
1718import androidx.annotation.ColorRes
1819import androidx.annotation.DrawableRes
1920import androidx.annotation.Size
@@ -96,6 +97,7 @@ interface DslSpanBuilder {
9697 // 设置文字颜色
9798 fun setForegroundColor (@Size(min = 1 ) colorString : String )
9899 fun setForegroundColor (@ColorRes colorId : Int )
100+ fun setForegroundColor (@ColorInt color : Int , isRes : Boolean = false)
99101 // 设置文字布局
100102 fun setAlignment (align : Layout .Alignment )
101103 // 设置文字大小
@@ -172,6 +174,11 @@ class DslSpanBuilderImpl(private val textView: TextView) : DslSpanBuilder {
172174 spanList.add(foregroundColorSpan)
173175 }
174176
177+ override fun setForegroundColor (@ColorInt color : Int , isRes : Boolean ) {
178+ foregroundColorSpan = ForegroundColorSpan (color)
179+ spanList.add(foregroundColorSpan)
180+ }
181+
175182 override fun setAlignment (align : Layout .Alignment ) {
176183 alignmentSpan = AlignmentSpan .Standard (align)
177184 spanList.add(alignmentSpan)
@@ -245,7 +252,7 @@ class DslSpanBuilderImpl(private val textView: TextView) : DslSpanBuilder {
245252 }
246253
247254 override fun setStyle (style : Int ) {
248- if (style in Typeface .NORMAL .. Typeface .BOLD_ITALIC ) {
255+ if (style in IntRange ( Typeface .NORMAL , Typeface .BOLD_ITALIC ) ) {
249256 styleSpan = StyleSpan (style)
250257 spanList.add(styleSpan)
251258 }
0 commit comments