GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Blogcat/Android-ExpandableTextView: An expandable TextView for Android applications

BranchesTags
Open more actions menu

Latest commit

 

History

105 Commits
105 Commits

Folders and files

NameName
Last commit message
Last commit date
app
app
 
 
expandabletextview
expandabletextview
 
 
gradle/wrapper
gradle/wrapper
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build.gradle
build.gradle
 
 
demo.gif
demo.gif
 
 
demo_interpolator.gif
demo_interpolator.gif
 
 
gradle.properties
gradle.properties
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
settings.gradle
settings.gradle
 
 

Repository files navigation

Android-ExpandableTextView

An expandable TextView for Android applications (4.1+).

Download

Latest Changes

  • Added support for Android O
  • Added RecyclerView Demo

Demo

This repository also contains a demo project.

Demo

Add dependency

This library is released in Maven Central and jCenter:

	repositories {
	    mavenCentral()
	}

or

	repositories {
	    jcenter()
	}

library dependency

	dependencies {
	    compile 'at.blogc:expandabletextview:1.0.5'
	}

Usage

Using the ExpandableTextView is very easy, it's just a regular TextView with some extra functionality added to it. By defining the android:maxLines attribute, you can set the default number of lines for the TextView collapsed state.

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <at.blogc.android.views.ExpandableTextView
        android:id="@+id/expandableTextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/lorem_ipsum"
        android:maxLines="5"
        android:ellipsize="end"
        app:animation_duration="750"/>

	<!-- Optional parameter animation_duration: sets the duration of the expand animation -->

    <Button
        android:id="@+id/button_toggle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/expand"/>

</LinearLayout>

In your Activity or Fragment:

final ExpandableTextView expandableTextView = (ExpandableTextView) this.findViewById(R.id.expandableTextView);
final Button buttonToggle = (Button) this.findViewById(R.id.button_toggle);

// set animation duration via code, but preferable in your layout files by using the animation_duration attribute
expandableTextView.setAnimationDuration(750L);

 // set interpolators for both expanding and collapsing animations
expandableTextView.setInterpolator(new OvershootInterpolator());

// or set them separately
expandableTextView.setExpandInterpolator(new OvershootInterpolator());
expandableTextView.setCollapseInterpolator(new OvershootInterpolator());

// toggle the ExpandableTextView
    buttonToggle.setOnClickListener(new View.OnClickListener()
    {
        @Override
        public void onClick(final View v)
        {
            buttonToggle.setText(expandableTextView.isExpanded() ? R.string.expand : R.string.collapse);
            expandableTextView.toggle();
        }
    });

// but, you can also do the checks yourself
buttonToggle.setOnClickListener(new View.OnClickListener()
{
    @Override
    public void onClick(final View v)
    {
        if (expandableTextView.isExpanded())
        {
            expandableTextView.collapse();
            buttonToggle.setText(R.string.expand);
        }
        else
        {
            expandableTextView.expand();
            buttonToggle.setText(R.string.collapse);
        }
    }
});

// listen for expand / collapse events
expandableTextView.setOnExpandListener(new ExpandableTextView.OnExpandListener()
{
    @Override
    public void onExpand(final ExpandableTextView view)
    {
        Log.d(TAG, "ExpandableTextView expanded");
    }

    @Override
    public void onCollapse(final ExpandableTextView view)
    {
        Log.d(TAG, "ExpandableTextView collapsed");
    }
});

License

Copyright 2016 Cliff Ophalvens (Blogc.at)

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

An expandable TextView for Android applications

www.blogc.at

Topics

androidandroid-expandabletextviewandroid-oreoexpandabletextviewtextview

Resources

Readme
Apache-2.0 license
Activity
Custom properties

Stars

300 stars

Watchers

9 watching

Forks

67 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.