ExpandableTextView
简介:可收缩展开的 TextView
ExpandableTextView library is a similar copy of
ExpandableTextView
by
Manabu Shimobe
, but change a little UI structure and improve the code to make it easier to use.

Setup
Download the library module and add it to your project.
Usage
Using the library is very simple, look at the source code of the provided sample.
Step 1. In your layout xml:
<me.chensir.expandabletextview.ExpandableTextView
android:id="@+id/tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentTextColor="@color/colorPrimary"
app:maxCollapsedLines="4">
</me.chensir.expandabletextview.ExpandableTextView>
Step 2. In your activity:
((ExpandableTextView) findViewById(R.id.tv)).setText(getString(R.string.dummy_text));
Just so !
Also , you can optionally set the following attributes in your layout xml file to customize the behavior of the ExpandableTextView.
maxCollapsedLines(defaults to 8) The maximum number of text lines allowed to be shown when the TextView gets collapsedanimDuration(defaults to 300ms) Duration of the Animation for the expansion/collapseexpandDrawableCustomize a drawable set to ImageButton to expand the TextViewcollapseDrawableCustomize a drawable set to ImageButton to collapse the TextViewcontentTextSizeCustomize the text size of contentcontentTextColorCustomize the text color of contentexpandTextCustomize the text forexpandDrawablecollapseTextCustomize the text forcollapseDrawableexpandCollapseTextColorCustomize the text color forexpandTextandcollapseTextDrawableAndTextGravityCustomize the gravity ofexpandDrawableandcollapseDrawablebelow the contentcontentLineSpacingMultiplierSets line spacing multiplier for the content text
本文介绍了一个可收缩展开的TextView组件——ExpandableTextView。该组件为Android应用提供了一种简单的方式来实现文本的展开与收缩功能。通过XML布局文件即可轻松配置,支持自定义文字颜色、字体大小、最大折叠行数等属性。
1988

被折叠的 条评论
为什么被折叠?



