背景
在開發過程中,當我們的需求中包含說說或者評論等內容的展示時,我們都會考慮當內容太多時該如何顯示。當內容的字數太多,如果全部展示出來可能會影響體驗效果,但是又不能只截取一部分內容進行展示,此時就需要考慮使用多行顯示折疊的效果來實現。
效果圖:
使用
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 /> <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 /> <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 /> <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" app:maxCollapsedLines="4" /> </LinearLayout>
本文標題:AndroidTextView實現多文本折疊、展開效果-創新互聯
本文來源:http://vcdvsql.cn/article38/cdiopp.html
成都網站建設公司_創新互聯,為您提供靜態網站、網站排名、響應式網站、網站收錄、App開發、企業建站
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯