Android 显示全文折叠控件

这篇博客介绍了如何在Android应用中实现一个全文折叠控件。当文本内容超过设定行数时,会显示折叠按钮,点击后可以展开全部内容。博客提供了布局文件和自定义控件的相关代码示例。
摘要由CSDN通过智能技术生成

转载请注明来源!

一般列表里文字太多的一个折叠效果的空间,效果图如下


这里写图片描述


当文字超过设定的行数后就折叠,小于设定行数不显示展开按钮。下面上代码。
先看布局文件:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@color/color_white" >
    <TextView
        android:id="@+id/desc_tv"
        style="@style/font2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center_vertical" />
    <TextView
        android:id="@+id/desc_op_tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/desc_tv"
        android:gravity="center_vertical"
        android:singleLine="true"
        android:text="@string/quan_wen"
        android:textColor="#5f897b"
        android:textSize="16sp"
        
  • 4
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值