【基础学习】Android可伸缩文本内容显示

来源:互联网 发布:unity3d教程百度云 编辑:程序博客网 时间:2024/06/05 19:15

介绍:

一个可以伸缩展开并且带平缓过渡动画的自定义文本控件,你可以设置其展开的行数,伸缩收起的图标,伸缩收起的文本和颜色等。

运行效果:

使用说明:

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_expandLinestvea_expandBitmaptvea_shrinkBitmaptvea_textContentColortvea_textContentSizetvea_textExpandtvea_textShrinktvea_textStateColor


源码:https://github.com/freecats/TextViewExpandableAnimation



0 0
原创粉丝点击