Reputation: 2310
I'm trying to set a single character in my TextView to transparent but also underlining that character. The underline should be visible.
Since I'm already using a SpannableStringBuilder I decided to try setting the foreground color for the character to transparent and then adding an underline span:
val foregroundColorSpan = ForegroundColorSpan(Color.TRANSPARENT)
val underlineSpan = UnderlineSpan()
spannableStringBuilder.setSpan(foregroundColorSpan, 2, 3, 0)
spannableStringBuilder.setSpan(underlineSpan, 2, 3, 0)
The only problem is the ForegroundColorSpan also changes the underline color to transparent. How can I prevent the underline from being transparent as well, or how could I hide the single character but also leave it visibly underlined?
I've seen some other solutions for changing the underline color but they used reflection and that is not an option I would like to go with.
Upvotes: 0
Views: 43