ExpandableTextView icon indicating copy to clipboard operation
ExpandableTextView copied to clipboard

Issue with SpannableString

Open yoobi opened this issue 1 year ago • 1 comments

Hello, I've tried using your library with the following:

When setting the text such as: binding.tvMessage.text = "Hello world" it does display the whole text but when using binding.tvMessage.text = SpannableString("Hello world") it only show the first letter then Show More button is displayed.

Note: This is reproductible with the sample app of the project.

binding.expandTvProg
    .setAnimationDuration(500)
    .setReadMoreText("View More")
    .setReadLessText("View Less")
    .setCollapsedLines(3)
    .setIsExpanded(false)
    .setIsUnderlined(true)
    .setExpandType(EXPAND_TYPE_LAYOUT)
    .setEllipsizedTextColor(ContextCompat.getColor(this, R.color.purple_200))

binding.expandTvProg.setText(SpannableString("Hello World"), TextView.BufferType.SPANNABLE)

yoobi avatar Feb 29 '24 14:02 yoobi

I have found the fix for this and it is quite simple:

You have to replace the isAllTextVisible

private fun String.isAllTextVisible(): Boolean = this == text

to

private fun String.isAllTextVisible(): Boolean = this == text.toString()

Tell me what you think about it :)

yoobi avatar Feb 29 '24 14:02 yoobi

Fixed on version 1.0.5

glailton avatar Apr 23 '25 01:04 glailton