All Projects → Blogcat → Android Expandabletextview

Blogcat / Android Expandabletextview

Licence: apache-2.0
An expandable TextView for Android applications

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Android Expandabletextview

LicenseTextView
Custom Lincese TextView for android
Stars: ✭ 31 (-88.43%)
Mutual labels:  textview
KodeEditor
A simple code editor with syntax highlighting and pinch to zoom
Stars: ✭ 60 (-77.61%)
Mutual labels:  textview
textmatcher
A simple text watcher that matches specific targets like mention or hashtag in a string by defining rules
Stars: ✭ 67 (-75%)
Mutual labels:  textview
Socially
Socially is a textView which is able to create separate clickable views according to your requirements.
Stars: ✭ 28 (-89.55%)
Mutual labels:  textview
embedded-text
Multiline TextBox for the embedded-graphics Rust crate
Stars: ✭ 35 (-86.94%)
Mutual labels:  textview
react-native-highlighted-text
A React Native component to individually style texts inside a text
Stars: ✭ 18 (-93.28%)
Mutual labels:  textview
Hyena
鬣狗快速开发库(2018年6月停止维护)
Stars: ✭ 21 (-92.16%)
Mutual labels:  textview
TTInputVisibilityController
Lightweight controller to keep your inputs visible when the keyboard is presented.
Stars: ✭ 21 (-92.16%)
Mutual labels:  textview
OutlineTextView
Android TextView with outline
Stars: ✭ 59 (-77.99%)
Mutual labels:  textview
extra-textview
additional features for TextView
Stars: ✭ 21 (-92.16%)
Mutual labels:  textview
STTextView
📝 STTextView is a light-weight library that adds a placeholder to the UITextView.
Stars: ✭ 36 (-86.57%)
Mutual labels:  textview
Android-SGTextView
同时带字体描边 渐变 阴影的TextView - both have stroker, gradient and shadow TextView
Stars: ✭ 18 (-93.28%)
Mutual labels:  textview
FSAnimatedTextView
Animated Number Text View Library
Stars: ✭ 32 (-88.06%)
Mutual labels:  textview
TextViewPlus
an android library for setting custom font in xml layout
Stars: ✭ 27 (-89.93%)
Mutual labels:  textview
LycricsTextView
No description or website provided.
Stars: ✭ 14 (-94.78%)
Mutual labels:  textview
hat-view
Allow to put "hat" on TextView. Inspired by Telegram appbar title with Santa Claus hat 🎅🏻
Stars: ✭ 51 (-80.97%)
Mutual labels:  textview
EasyMoney-Widgets
The widgets (EditText and TextView) for support of money requirements like currency, number formatting, comma formatting etc.
Stars: ✭ 91 (-66.04%)
Mutual labels:  textview
Gradienttextview
一个颜色逐渐改变的textview,类似歌词效果
Stars: ✭ 267 (-0.37%)
Mutual labels:  textview
CustomFontView
Custom View classes for TextView, EditText & Buttons - to set custom fonts
Stars: ✭ 26 (-90.3%)
Mutual labels:  textview
FOTextLayout
实现文字横竖向切换,实现各种文字的排版,可以某种程度上替代UILabel。
Stars: ✭ 36 (-86.57%)
Mutual labels:  textview

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].