I have a TextView
that shows 7 lines at a time. I am trying to put an icon below the TextView
, so that if I click the icon, the next 7 lines will appear if there are more lines.
<TextView
android:id="@+id/tvDesc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="7"
android:scrollbars="vertical"
android:paddingTop="3dp"
android:paddingLeft="7dp"
android:paddingRight="7dp"
android:layout_alignTop="@+id/curl"
android:layout_alignLeft="@+id/curl"
android:textSize="16dp"
android:text=""
android:fadeScrollbars="false"
android:textColor="#000000" />
<ImageView
android:id="@+id/iv_scrollD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_below="@+id/tvmsg"
android:layout_alignParentLeft="true"
android:src="@drawable/plus_24" />
Can anybody help in this, please?
You are implementing something similar to "Show more" option used frequently. This exact problem is answered here .
use a SpannableStringBuilder
to show "Show more" and "Show less" strings (the text under textView you are talking about. Please refer to the answer for more details.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.