背景
在开发过程中,当我们的需求中包含说说或者评论等内容的展示时,我们都会考虑当内容太多时该如何显示。当内容的字数太多,如果全部展示出来可能会影响体验效果,但是又不能只截取一部分内容进行展示,此时就需要考虑使用多行显示折叠的效果来实现。
效果图:
使用
1.布局文件调用
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.wiggins.expandable.widget.MoreLineTextView
android:id="@+id/tv_more_line_short"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:padding="@dimen/padding_small"
app:clickAll="true"
app:textColor="@color/red" />
<View style="@style/spaceLine" />
<com.wiggins.expandable.widget.expandable.ExpandableTextView
android:id="@+id/tv_expandable_short"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:ellipsize="end"
android:padding="@dimen/padding_small"
android:textColor="@color/blue"
app:allClickable="false"
app:contentTextColor="@color/blue"
app:isDisplayIcon="false"
app:maxCollapsedLines="4" />
<View style="@style/spaceLine" />
<com.wiggins.expandable.widget.MoreLineTextView
android:id="@+id/tv_more_line_long"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:padding="@dimen/padding_small"
app:clickAll="true"
app:textColor="@color/red" />
<View style="@style/spaceLine" />
<com.wiggins.expandable.widget.expandable.ExpandableTextView
android:id="@+id/tv_expandable_long"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:ellipsize="end"
android:padding="@dimen/padding_small"
android:textColor="@color/blue"
app:allClickable="false"
app:contentTextColor="@color/blue"
app:isDisplayIcon="false"
a