0

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?

Saumik Bhattacharya
  • 891
  • 1
  • 12
  • 28

1 Answers1

0

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.

Community
  • 1
  • 1
VipulKumar
  • 2,385
  • 1
  • 22
  • 28