mike5v / viewmore-textview

A simple library for hide and show text with animation.
Apache License 2.0
89 stars 13 forks source link

ViewMore TextView Download

ViewMore TextView allows you to use a TextView by hiding the content of the text by a number of established lines and to display all the content expanding the TextView by a collapsing/expanding animation. It's possibile use an ellipses text or a foreground color gradient or both to hide the content. 🚀

Here some examples:

example example

Setup

In your Gradle dependencies add:

implementation "it.mike5v:viewmore-textview:$latest_release"

Usage

    <it.mike5v.viewmoretextview.ViewMoreTextView
        android:id="@+id/viewMore"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="32dp"
        android:layout_marginTop="32dp"
        android:layout_marginRight="32dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:ellipsizeText="View More"
        app:duration="500"
        app:visibleLines="3"
        app:isExpanded="false"/>

or programmatically

viewMore
    .setAnimationDuration(500)
    .setEllipsizedText("View More")
    .setVisibleLines(3)
    .setIsExpanded(false)
    .setEllipsizedTextColor(ContextCompat.getColor(this, R.color.colorAccent))

and

viewMore.setOnClickListener {
    viewMore.toggle()
}