I have a scrollable textView, and I want to limit the number of lines displayed, however xml properties are not working :
I tried as said in accepted answer and others but didn't worked for me, but after adding android:ellipsize="marquee"
it's working now..
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="120dip" >
<TextView
android:id="@+id/tv_addesc"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxLines="12"
android:scrollbars="vertical"
android:textColor="#FFFFFFFF"
android:textSize="15sp" />
</ScrollView>
Try using this.
android:maxLines="12"
android:ellipsize="end"
In the end it add ... if extra text available.
You can also use
android:ellipsize="marquee"
It will reduce extra text from end that is not like a word.
You just have to set a number of lines in your TextView
like this:
android:maxLines = "10"
and you must also add:
android:minLines="1"
The rest of this not necessary if you are not using scrolling
and a property which says that this TextView should be scrollable vertically:
android:scrollbars = "vertical"
And in your Java-code:
yourTextView.setMovementMethod(new ScrollingMovementMethod())
Find your textview by id:
TextView myTextBox=(TextView)findViewById(R.id.textBox);
Now use the setMaxLines function and assign the number of lines you require in it,say 20.
myTextBox.setMaxLines(20);
This limits your text box to show 20 lines only.
hey try setting the singleline property to false. Just see if it works.