I have the following TextView
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="3"
android:text="Large text"
android:ellipsize="end" />
When I calling textView.getLineCount()
I always get 3
. But I want to get "Real number of lines" which hidden because I'm using maxLines
. How can I do that?
在xml代码中,将其添加到TextView中:
android:inputType = "textMultiLine"
Use TextView.getLayout()
to access information about the actual text currently being laid out.
TextView tv = findViewById(R.id.textView);
int realLines = tv.getLayout().getLineCount();
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.