Skip to content

Repository files navigation

banner_lib

LicenseAPIrepo size

forksstars

Android CI

🏁 Including in your project

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.iamageo:another-read-more-lib:1.0.3'
}

🛠 Library Attributes

AttributesTypeDefaultDescription
textLengthInt0Minimal text to show labels.
textLengthTypeInt TYPE_LINE(1) or TYPE_CHARACTER(2)0Indicates whether text trimming should be done by number of characters or by number of lines.
moreLabelStringnonetext of more label.
lessLabelStringnonetext of less label.
moreLabelColorIntColor.BLACKColor from moreLabel.
lessLabelColorIntColor.BLACKColor from lessLabel.
underlineVisibleBooleantrueShow/hide underline in more and less labels.

✨ Basic example for Kotlin

val tv = findViewById<TextView>(R.id.mTextView)
val anotherReadMore:AnotherReadMore=AnotherReadMore.Builder(this)
.textLength(100, AnotherReadMore.TYPE_LINE)
.moreLabel("mais")
.lessLabel("menos")
.build()
anotherReadMore.addReadMoreTo(tv,"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.")

Example with RecyclerView

internalclassSimpleAnotherAdapter internal constructor(privatevalcontext:Context) :
RecyclerView.Adapter<SimpleAnotherAdapter.ViewHolder>() {
privateval anotherReadMore:AnotherReadMore=AnotherReadMore.Builder(context)
.build()
internalclassViewHolder(v:View) : RecyclerView.ViewHolder(v) {
var mTextView:TextView= v.findViewById(R.id.tv)
}
overridefunonCreateViewHolder(
parent:ViewGroup,
viewType:Int
): ViewHolder {
val v =LayoutInflater.from(parent.context)
.inflate(R.layout.item, parent, false) asViewreturnViewHolder(v)
}
overridefunonBindViewHolder(holder:ViewHolder, position:Int) {
if (position %2==0) {
anotherReadMore.addReadMoreTo(
holder.mTextView,
Html.fromHtml(context.getString(R.string.big_text))
)
} else {
anotherReadMore.addReadMoreTo(
holder.mTextView,
Html.fromHtml(context.getString(R.string.big_text)).toString()
)
}
}
overridefungetItemCount(): Int {
return30
}
}

License


Copyright 2022 Geovani Amaral
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

📖 Another Read More Library is a simple TextView with read more text

Topics

Resources

Stars

18 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages