最多展示两行文字 超出末尾显示省略号 并且在第三行开头展示“展开”按钮
点击展开或文字后 文字全部显示 展开按钮变成收起按钮 点击文字或收起按钮则文字变为两行 显示展开
文字不超过两行正常显示 无展开按钮
布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/feedback_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="24px"
android:paddingRight="24px"
android:orientation="vertical">
<TextView
android:id="@+id/feedback_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:textColor="@color/color_99FFFFFF"
android:textSize="30px" />
<LinearLayout
android:id="@+id/show_feedback"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:pa

这篇博客介绍了如何在Android应用中创建一个工具类,用于实现文字内容的展开和收起功能。当文字超过两行时,末尾显示省略号,并提供一个‘展开’按钮,点击后显示完整内容,按钮变为‘收起’。再次点击,内容恢复为两行并隐藏剩余部分。文章还提到了布局设计和可能使用的编程语言如Kotlin。
最低0.47元/天 解锁文章
3765

被折叠的 条评论
为什么被折叠?



