Convert your TextView in ExpandableTextView with added options ReadMore/ReadLess.
This is just an updated version of ReadMoreOptions and applying some of the active pull requests in it. Credits go completely to its creator and the people who has contributed with those pull requests.
Gradle
-
Step 1. Add the JitPack repository to your build file
Add it in your root build.gradle at the end of repositories:
allprojects { repositories { ... maven { url 'https://jitpack.io' } } }
-
Step 2. Add the dependency
dependencies { implementation 'com.github.leodan11:ReadMoreOptions:{latest version}' }
Kotlin
-
Step 1. Add the JitPack repository to your build file.
Add it in your root build.gradle at the end of repositories:
repositories { ... maven(url = "https://jitpack.io") } -
Step 2. Add the dependency
dependencies { implementation("com.github.leodan11:ReadMoreOptions:${latest version}") }
val readMoreOption = ReadMoreOption.Builder(this)
.textLength(3)
.labelUnderLine(true)
//.moreLabelColor(Color.BLUE) Optional
//.moreLabel(getString(R.string.text_value_read_more)) Optional
//.lessLabelColor(Color.RED) Optional
//.lessLabel(getString(R.string.text_value_read_less)) Optional
.textLengthType(ReadMoreOption.TYPE_LINE) // Or .textLengthType(ReadMoreOption.TYPE_CHARACTER)
.expandAnimation(true)
.build()
readMoreOption.addReadMoreTo(textViewExample, R.string.text_value) //Or addReadMoreTo(textViewExample, "Example Text")