Skip to content

Commit

Permalink
1,新增支持图片
Browse files Browse the repository at this point in the history
2,支持下划线定制
  • Loading branch information
FlyJingFish committed Sep 7, 2022
1 parent 454f5c7 commit fd8c093
Show file tree
Hide file tree
Showing 13 changed files with 543 additions and 61 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.flyjingfish.formattextview

open class BaseFormat {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package com.flyjingfish.formattextview

import android.text.style.ImageSpan
import androidx.annotation.DrawableRes

class FormatImage : BaseFormat() {
companion object StaticField {
@kotlin.jvm.JvmField
val ALIGN_BOTTOM: Int = ImageSpan.ALIGN_BOTTOM

@kotlin.jvm.JvmField
val ALIGN_BASELINE: Int = ImageSpan.ALIGN_BASELINE

@kotlin.jvm.JvmField
var ALIGN_CENTER: Int = ImageSpan.ALIGN_CENTER
}


@JvmField
var imageUrlValue: String? = null

@JvmField
@DrawableRes
var imageResValue = 0

@JvmField
@DrawableRes
var imagePlaceHolder = 0

@JvmField
var width = 0f

@JvmField
var height = 0f

@JvmField
var verticalAlignment = ALIGN_BASELINE

@JvmField
var marginLeft = 0f

@JvmField
var marginRight = 0f

@JvmField
var marginStart = 0f

@JvmField
var marginEnd = 0f

fun setImageUrlValue(imageUrlValue: String?): FormatImage {
this.imageUrlValue = imageUrlValue
return this
}

fun setImageResValue(@DrawableRes imageResValue: Int): FormatImage {
this.imageResValue = imageResValue
return this
}

fun setWidth(width: Float): FormatImage {
this.width = width
return this
}

fun setHeight(height: Float): FormatImage {
this.height = height
return this
}

fun setVerticalAlignment(verticalAlignment: Int): FormatImage {
this.verticalAlignment = verticalAlignment
return this
}

fun setImagePlaceHolder(@DrawableRes imagePlaceHolder: Int): FormatImage {
this.imagePlaceHolder = imagePlaceHolder
return this
}

fun setMarginLeft(marginLeft: Float): FormatImage {
this.marginLeft = marginLeft
return this
}

fun setMarginRight(marginRight: Float): FormatImage {
this.marginRight = marginRight
return this
}

fun setMarginStart(marginStart: Float): FormatImage {
this.marginStart = marginStart
return this
}

fun setMarginEnd(marginEnd: Float): FormatImage {
this.marginEnd = marginEnd
return this
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,93 @@ package com.flyjingfish.FormatTexttextview

import androidx.annotation.ColorRes
import androidx.annotation.StringRes
import com.flyjingfish.formattextview.BaseFormat

class FormatText {
class FormatText : BaseFormat() {

@JvmField
@ColorRes
var color = 0
var textColor = 0

@JvmField
var bold = false

@JvmField
var underline = false

@JvmField
var italic = false

@JvmField
var strValue: String? = null

@JvmField
@StringRes
var resValue = 0
var textSize = 0;

@JvmField
var textSize = 0

@JvmField
@ColorRes
var underlineColor = 0

@JvmField
var underlineWidth = 0f

@JvmField
var underlineTopForBaseline = 0f

fun setTextColor(@ColorRes color: Int): FormatText {
this.color = color
this.textColor = color
return this
}

fun setTextBold(bold: Boolean): FormatText {
fun setBold(bold: Boolean): FormatText {
this.bold = bold
return this
}

fun setTextUnderline(underline: Boolean): FormatText {
fun setUnderline(underline: Boolean): FormatText {
this.underline = underline
return this
}

fun setTextItalic(italic: Boolean): FormatText {
fun setItalic(italic: Boolean): FormatText {
this.italic = italic
return this
}

fun setTextStrValue(strValue: String?): FormatText {
fun setStrValue(strValue: String?): FormatText {
this.strValue = strValue
return this
}

fun setTextResValue(@StringRes resValue: Int): FormatText {
fun setResValue(@StringRes resValue: Int): FormatText {
this.resValue = resValue
return this
}

fun setTextSizes(textSize: Int): FormatText {
fun setTextSize(textSize: Int): FormatText {
this.textSize = textSize
return this
}


fun setUnderlineColor(@ColorRes color: Int): FormatText {
this.underlineColor = color
return this
}

fun setUnderlineWidth(width: Float): FormatText {
this.underlineWidth = width
return this
}

fun setUnderlineTopForBaseline(underlineTop: Float): FormatText {
this.underlineTopForBaseline = underlineTop
return this
}


}
Loading

0 comments on commit fd8c093

Please sign in to comment.