Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/eriffanani/TextViewReadMore

Android library for creating expand button on your long textview
https://github.com/eriffanani/TextViewReadMore

android android-library endlesstext expandabletext expandabletextview java kotlin longtext readmore textview-android textviews

Last synced: about 2 months ago
JSON representation

Android library for creating expand button on your long textview

Awesome Lists containing this project

README

        

# TextView Read More
Make your long textview setup easily and quickly

## Installation
#### settings.gradle
```kotlin
dependencyResolutionManagement {
repositories {
maven { url 'https://jitpack.io' }
}
}
```

#### build.gradle(app)
```kotlin
dependencies {
implementation 'com.github.eriffanani:TextViewReadMore:4.1.0'
}
```

## How To Use
* Basic
```xml

```
![basic](https://user-images.githubusercontent.com/26743731/167334745-3915b937-a0b4-4524-a0b4-47b165143ec7.png)

#### Styling
* Expand
```xml

```
![styling](https://user-images.githubusercontent.com/26743731/167335646-86eb9860-b40e-4281-be49-644993cd49e1.png)

* Collapse
```xml

```

### Animation
```xml

```

### Ellipsis Type
```xml

```
### Action
```xml

```
```java
TextViewReadMore txtReadMore = findViewById(R.id.txtReadMore);
txtReadMore.onClickExpand(v -> txtReadMore.toggle());
txtReadMore.onClickCollapse(v -> txtReadMore.toggle());
```

### Listener
* Java
```Java
txtReadMore.toggleListener(collapsed -> { // TODO ACTION });
```
* Kotlin
```kotlin
txtReadMore.toggleListener { collapsed -> // TODO ACTION }
```

## Result

### With recyclerview
* Use collapse function to onBindViewHolder
```java
/**
item.isCollapsed() is variable from your item to store and save state of
textview (collapsed/expanded) when item displayed again from RecyclerView scroll
*/
holder.text.collapsed(item.isCollapsed());
```
* Use Toggle
```java
holder.text.onClickExpand(v -> holder.text.toggle());
holder.text.onClickCollapse(v -> holder.text.toggle());
holder.text.toggleListener(collapsed -> {
item.setCollapsed(collapsed);
notifyItemChanged(position);
});
```
* Use Collapse Properties
```java
// onClickExpand or onClickCollapse
holder.text.onClickExpand(v -> {
boolean status = !item.isCollapsed();
holder.text.collapsed(status);
item.setCollapsed(status);
notifyItemChanged(position);
});
```
## Result

#### Information
This library is still being developed further, please provide feedback if you find a bug. Thank you
### Licence
```license
Copyright 2022 Mukhammad Erif Fanani

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.
```