非常简单实现可折叠textview并带有省略号
来源:互联网 发布:电脑没有usb打印端口 编辑:程序博客网 时间:2024/04/28 07:45
效果如图
之前看到的可折叠textview都是代码一大堆,用起来麻烦。我这个方案不用写自定义控件,简单粗暴,直接达成目的。
布局文件
<RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:text="为天地立心,为生民立命,为往圣继绝学,为万世开太平。哈哈哈哈,强势装一波。" android:id="@+id/tv_cbf" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginLeft="5dp" android:layout_marginRight="25dp" android:ellipsize="end" android:maxLines="1" android:textColor="@color/hint" /> <ImageView android:id="@+id/iv_cbf" android:layout_width="20dp" android:layout_height="20dp" android:layout_alignParentRight="true" android:background="@mipmap/down_arrow" /> </RelativeLayout>设置默认maxlines是一排,并将ellipsize设置为end,旁边的imageview是按钮,然后设置监听
if (tvCbf.getMaxLines()==1){ tvCbf.setMaxLines(10); ivCbf.setBackgroundResource(R.mipmap.up_arrow); }else{ tvCbf.setMaxLines(1); ivCbf.setBackgroundResource(R.mipmap.down_arrow); }如果当前的textview的maxlines是1,那么久设置一个比较的数,并将图片换一张,或者用动画旋转。这种绝对是最简单的实现方式,并且亲测有效。
0 0
- 非常简单实现可折叠textview并带有省略号
- TextView最后一行实现省略号
- android TextView自动实现省略号
- Latex带有省略号矩阵的实现
- Android TextView 实现文字过长省略号.....
- 使用EditText 代替textview实现末尾省略号
- CollapsedTextView可折叠的textview,几行代码就能搞定,非常方便使用
- TextView省略号
- TextView,省略号
- Android可折叠的textview
- 自定义可折叠textview
- jquery实现的非常简单实用带有渐变切换效果的tab选项卡
- 可折叠展开的TextView -- ExpandableTextView
- 仿微信可折叠效果的TextView
- 可折叠TextView控件使用:ExpandableTextView
- Android中的TextView实现多行显示省略号
- Android中的TextView实现多行显示省略号
- Android中的TextView实现多行显示省略号 .
- Ubuntu 安装SDN Floodlight 遇到的问题及解决方法
- g++报错原因分析:expected class-name before ‘{’ token
- 统计一个数在计算机由几个1存储
- 01-gradle学习认识gradle
- 爱思助手无法连接或者连接超时解决办法
- 非常简单实现可折叠textview并带有省略号
- JDK源码学习之Arraylist与LinkedList
- 关于jQuery EasyUI 中刷新Tab选项卡 后一个页面变形的问题的解决方法
- IOS GCD
- Json解析之动态key和key为关键字问题(JAVA初级)
- GreenDao 的基本使用
- IE兼容性问题(一)
- maven +jfinal +bettl 整合
- 题意就是让我们找一个数只能有三个约数,很明显素数有两个,那么容易找到规律,这个数只能有着三个约数。1和自己还有sqrt(n)。sqrt(n)自然要是素数