前言介绍
想必现如今在很多App软件上都能见到文本折叠伸缩效果,这篇文章我们来讲解一下它的实现。
大家先看看效果图!
效果图
- 在文章内容显示达到三行时,显示省略号,并可点击
展开
查看全文 - 全文查看显示时,可点击
收缩
,恢复原状 ,显示三行文章内容; - 注: 这里的展开、收缩关键字一句布局界面 可以根据的需求进行更替,并非只能如此。
操作流程
1. 先看看 我们的xml布局设计
- tvContentTwo: 此 TextView 控件内容为我们需要填入的文章内容的
- tvTelescopicTwo:此TextView 控件内容 是关键字,点击伸缩展示全部文章内容
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
tools:context=".Main2Activity">
<TextView
android:id="@+id/tvContentTwo"