如何使用ExpandableTextView
2016-10-22 17:27
218 查看
展现文字折叠效果 如图
原本以为要自己自定义,后来才知道已经第三方控件,直接拿来用就好了
使用方法:
新建一个工程
然后fbc
然后就可以了
注意要在ExpandableTextView 里面设置文本内容
原本以为要自己自定义,后来才知道已经第三方控件,直接拿来用就好了
使用方法:
新建一个工程
dependencies 添加
compile 'com.ms-square:expandableTextView:0.1.4'XML 布局文件
<com.ms.square.android.expandabletextview.ExpandableTextView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:expandableTextView="http://schemas.android.com/apk/res-auto" android:id="@+id/expand_text_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" expandableTextView:maxCollapsedLines="5" expandableTextView:animDuration="200"> <TextView android:id="@id/expandable_text" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:textSize="16sp" android:text="aasdasdasdasdasdas" android:textColor="#666666" /> <ImageButton android:id="@id/expand_collapse" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="16dp" android:layout_gravity="right|bottom" android:background="@android:color/transparent"/> </com.ms.square.android.expandabletextview.ExpandableTextView>
然后fbc
private void initView() { ExpandableTextView expand_text_view= (ExpandableTextView) findViewById(R.id.expand_text_view); expand_text_view.setText("\n" + "予观夫巴陵胜状,在洞庭一湖。衔远山,吞长江,浩浩汤汤,横无际涯;朝晖夕阴,气象万千。此则岳阳楼之大观也,前人之述备矣。然则北通巫峡,南极潇湘,迁客骚人,多会于此,览物之情,得无异乎?\n" + "若夫淫雨霏霏,连月不开,阴风怒号,浊浪排空;日星隐曜,山岳潜形;商旅不行,樯倾楫摧;薄暮冥冥,虎啸猿啼。登斯楼也,则有去国怀乡,忧谗畏讥,满目萧然,感极而悲者矣。\n"); }
然后就可以了
注意要在ExpandableTextView 里面设置文本内容
相关文章推荐
- Android TextView 中如何使用第三方字体
- 开源项目ExpandableTextView使用和源码分析
- Android中如何使用View填充在多个TextView之间使之等间距
- 数据库数据添加到TextView详解(limite参数如何使用)
- 可扩展的TextView,ExpandableTextView与Scroller类的使用
- TextView显示丰富多彩的文字(二)——如何使用ParagraphStyle格式化段落
- 如何使用一个textview控件使字体出现两种颜色
- Android中的如何在代码中使用64位颜色值改变TextView的颜色的方法
- 可折叠TextView控件使用:ExpandableTextView
- 使用ExpandableTextView遇到的坑
- TextView显示丰富多彩的文字(一)——如何使用CharacterStyle格式化字符
- 如何实现在TextView使用占位符(placeholder)
- 【ANDROID自定义控件】可扩展的TextView,ExpandableTextView与Scroller类的使用
- 如何在一个textview中使用不同颜色的字体
- Android如何使用java改变TextView的宽高,设置全屏
- [android]如何让TextView使用超链接
- 如何使用gdb调试代码(一、A Globla view of GDB )
- JSP设计模式基础:View Helper模式——学习如何使用View Helper模式使得Model数据适应表现层的需要(1)
- AutoCompleteTextView的使用
- Android入门逆引手册 - 09 文本框(TextView)的使用