![](https://camo.githubusercontent.com/8d60f9364febd367a3d3e24c88ec9fe10fc0c27fe7963896e48b281e3e3f62b6/68747470733a2f2f696d672d626c6f672e6373646e696d672e636e2f32303139313033303137333535383130392e706e673f782d6f73732d70726f636573733d696d6167652f77617465726d61726b2c747970655f5a6d46755a33706f5a57356e6147567064476b2c736861646f775f31302c746578745f6148523063484d364c7939696247396e4c6d4e7a5a473475626d56304c334e70626d4630587a4d7a4d5455774e4445332c73697a655f31362c636f6c6f725f4646464646462c745f3730)
![](https://camo.githubusercontent.com/ed8e03fc90475016a3aa8dcc7b524b2e9896ac308bd98cc3279414c5a0a8bfdc/68747470733a2f2f696d672d626c6f672e6373646e696d672e636e2f32303139313033303137333631323339302e706e673f782d6f73732d70726f636573733d696d6167652f77617465726d61726b2c747970655f5a6d46755a33706f5a57356e6147567064476b2c736861646f775f31302c746578745f6148523063484d364c7939696247396e4c6d4e7a5a473475626d56304c334e70626d4630587a4d7a4d5455774e4445332c73697a655f31362c636f6c6f725f4646464646462c745f3730)
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.zhangtiansimple:FoldTextView:1.0.3'
}
<com.link.foldtextviewlibrary.FoldTextView
android:id="@+id/fold_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_marginTop="30dp"
android:layout_marginEnd="15dp"
app:contentTextColor="@color/colorPrimary"
app:foldText="More"
app:contentLineSpaceMultiplier="1.2"
app:foldDrawable="@drawable/ic_fold"
app:unFoldDrawable="@drawable/ic_unfold"
app:stateTvGravity="left"
app:stateTextColor="@color/colorPrimary"
app:unFoldText="Less" />
FoldTextView mFoldTextView = findViewById(R.id.fold_text_view);
mFoldTextView.setText("your content");
mFoldTextView.setStatusListener(new FoldStatusListener() {
@Override
public void onFoldStateChanged(TextView tv, boolean isFold) {
if (isFold) {
Log.d(TAG, "isFold");
} else {
Log.d(TAG, "isUnfold");
}
}
});
可选属性 |
取值 |
maxUnfoldLines |
折叠最大行数,默认为3 |
animDuration |
展开收起动画执行时常,默认300毫秒 |
contentTextSize |
内容字体大小,默认16 |
contentTextColor |
内容字体颜色,默认为Color.BLACK |
contentLineSpaceMultiplier |
内容行间距,默认为1.0 |
unFoldDrawable |
展开icon,默认为效果图最上黑色三角 |
foldDrawable |
折叠icon,默认为效果图最上黑色三角 |
unFoldText |
折叠文案,默认为“折叠” |
foldText |
展开文案,默认为“展开” |
stateTextColor |
展开折叠状态文字颜色 |
stateTvGravity |
展开折叠状态文字Gravity |