Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/eriffanani/TextViewReadMore
- Owner: eriffanani
- License: apache-2.0
- Created: 2022-04-29T08:38:41.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-08-28T06:41:16.000Z (over 1 year ago)
- Last Synced: 2024-08-02T19:33:46.043Z (5 months ago)
- Topics: android, android-library, endlesstext, expandabletext, expandabletextview, java, kotlin, longtext, readmore, textview-android, textviews
- Language: Java
- Homepage:
- Size: 352 KB
- Stars: 13
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-list - eriffanani/TextViewReadMore - Android library for creating expand button on your long textview (Java)
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 FananiLicensed 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 athttp://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.
```