【基础学习】Android可伸缩文本内容显示
介绍:
一个可以伸缩展开并且带平缓过渡动画的自定义文本控件,你可以设置其展开的行数,伸缩收起的图标,伸缩收起的文本和颜色等。
运行效果:

使用说明:
把TextViewExpandableAnimation.java以及一些资源文件比如attrs.xml拷贝到你的项目。
xml
<com.freecats.demo.view.TextViewExpandableAnimation xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/tv_expand" android:layout_width="wrap_content" android:layout_height="wrap_content" app:tvea_expandBitmap="@drawable/icon_green_arrow_down" app:tvea_expandLines="3" app:tvea_shrinkBitmap="@drawable/icon_green_arrow_up" app:tvea_textContentColor="@color/color_gray_light_content_text" app:tvea_textContentSize="@dimen/sp_txt_size_content" app:tvea_textExpand="@string/expand" app:tvea_textShrink="@string/shrink" app:tvea_textStateColor="@color/colorPrimary" />
java
TextViewExpandableAnimation tvExpand = (TextViewExpandableAnimation) findViewById(R.id.tv_expand); tvExpand.setText(text);
支持以下属性:
tvea_expandLines |
tvea_expandBitmap |
tvea_shrinkBitmap |
tvea_textContentColor |
tvea_textContentSize |
tvea_textExpand |
tvea_textShrink |
tvea_textStateColor |