Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Android library for creating expand button on your long textview

License

NotificationsYou must be signed in to change notification settings

eriffanani/TextViewReadMore

Repository files navigation

Make your long textview setup easily and quickly

Installation

settings.gradle

dependencyResolutionManagement {    repositories {        maven { url'https://jitpack.io' }    }}

build.gradle(app)

dependencies {    implementation'com.github.eriffanani:TextViewReadMore:4.1.0'}

How To Use

  • Basic
<com.erif.readmoretextview.TextViewReadMoreandroid:layout_width="wrap_content"android:layout_height="wrap_content"app:readMoreMaxLines="3" (Default 1)android:text="YOUR TEXT HERE"/>

basic

Styling

  • Expand
<com.erif.readmoretextview.TextViewReadMoreapp:readMoreMaxLines="3" (Default 1)app:expandText="Open Text" (Default"Read More")app:expandTextColor="@color/teal_200" (Default Color.BLUE)app:expandTextStyle="bold|italic" (Default normal)app:expandTextUnderline="true" (Default false)android:text="YOUR TEXT HERE"/>

styling

  • Collapse
<com.erif.readmoretextview.TextViewReadMoreapp:collapseText="Close Text" (Default"Close")app:collapseTextColor="@color/teal_200" (Default Color.BLUE)app:collapseTextStyle="bold|italic" (Default normal)app:collapseTextUnderline="true" (Default false)app:collapsed="false" (Default true)/>

Animation

<com.erif.readmoretextview.TextViewReadMoreapp:duration="200"app:interpolator=""app:interpolatorExpand="bounce"app:durationExpand="800"app:interpolatorCollapse="anticipate_overshoot"app:durationCollapse="900"/><!--Animation Interpolator--><flagname="decelerate"/><flagname="accelerate"/><flagname="anticipate_overshoot"/><flagname="anticipate"/><flagname="bounce"/><flagname="fast_out_linear_in"/><flagname="fast_out_slow_in"/><flagname="linear_out_slow_in"/>

Ellipsis Type

<com.erif.readmoretextview.TextViewReadMoreapp:ellipsisType="none" (Default dots)/>

Action

<com.erif.readmoretextview.TextViewReadMoreapp:actionClickColor="@color/colorRed" (Default @color/text_view_read_more_button_hover_color)/>
TextViewReadMoretxtReadMore =findViewById(R.id.txtReadMore);txtReadMore.onClickExpand(v ->txtReadMore.toggle());txtReadMore.onClickCollapse(v ->txtReadMore.toggle());

Listener

  • Java
txtReadMore.toggleListener(collapsed -> {// TODO ACTION });
  • Kotlin
txtReadMore.toggleListener { collapsed->// TODO ACTION }

Result

With recyclerview

  • Use collapse function to onBindViewHolder
/**    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
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
// onClickExpand or onClickCollapseholder.text.onClickExpand(v -> {booleanstatus = !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

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 at  http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed 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 andlimitations under the License.

[8]ページ先頭

©2009-2025 Movatter.jp