File tree Expand file tree Collapse file tree 3 files changed +18
-5
lines changed
java/com/omega_r/libs/views Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Original file line number Diff line number Diff line change 1818 app : startTextFont =" sans-serif-thin"
1919 app : endText =" @string/app_name"
2020 app : endTextStyle =" bold|underline"
21+ app : includeTextSpace =" true"
2122 app : layout_constraintBottom_toBottomOf =" parent"
2223 app : layout_constraintLeft_toLeftOf =" parent"
2324 app : layout_constraintRight_toRightOf =" parent"
Original file line number Diff line number Diff line change @@ -36,9 +36,14 @@ open class OmegaTextView @JvmOverloads constructor(
3636 var endText: Text ? = null
3737 set(value) {
3838 field = value
39- if (initData) {
40- updateAllText()
41- }
39+ updateAllText()
40+
41+ }
42+
43+ var spaceText: Text ? = null
44+ set(value) {
45+ field = value
46+ updateAllText()
4247 }
4348
4449 private val startTextStyle = Style ()
@@ -83,6 +88,11 @@ open class OmegaTextView @JvmOverloads constructor(
8388 R .styleable.OmegaTextView_endTextFont -> {
8489 endTextStyle.fontFamily = a.getString(attr)
8590 }
91+ R .styleable.OmegaTextView_includeTextSpace -> {
92+ if (a.getBoolean(attr, false )) {
93+ spaceText = Text .from(" " )
94+ }
95+ }
8696
8797 }
8898 }
@@ -103,8 +113,8 @@ open class OmegaTextView @JvmOverloads constructor(
103113
104114 private fun updateAllText (force : Boolean = false) {
105115 if (initData || force) {
106- val allText = (startText + startTextStyle) + text + (endText + endTextStyle)
107- super .setText(allText?.getCharSequence(context), BufferType .SPANNABLE )
116+ val allText = (startText + startTextStyle) + spaceText + text + spaceText + (endText + endTextStyle)
117+ super .setText(allText?.getCharSequence(context), BufferType .NORMAL )
108118 }
109119 }
110120
Original file line number Diff line number Diff line change 2727 <attr name =" startTextFont" format =" string" />
2828 <attr name =" endTextFont" format =" string" />
2929
30+ <attr name =" includeTextSpace" format =" boolean" />
31+
3032 </declare-styleable >
3133
3234</resources >
You can’t perform that action at this time.
0 commit comments