How to implement horizontal and vertical scrolling of TextView in Android

Source: Internet
Author: User

1. What should I do if I only want TextView to display a row, but the text exceeds the length of TextView?
Show ellipsis at the beginning
[Html] android: singleLine = "true"
Android: ellipsize = "start"
Show ellipsis at the end
[Html]
Android: singleLine = "true"
Android: ellipsize = "end"
Show ellipsis in the middle
[Html]
Android: singleLine = "true"
Android: ellipsize = "middle"
Automatic horizontal scrolling (running horse light effect)
[Html]
Android: singleLine = "true"
Android: ellipsize = "marquee"
Android: marqueeRepeatLimit = "marquee_forever"
Android: focusable = "true"
Android: focusableInTouchMode = "true"
Android: singleLine = "true" must be added to all the above four effects, because TextView will automatically wrap by default.
Android: ellipsize indicates how to display long text
Android: marqueeRepeatLimit = "marquee_forever" indicates that the settings are always repeated. You can also set specific numbers.
Android: focusable = "true" and android: focusableInTouchMode = "true" must be added. Otherwise, the rolling effect will fail.


2. How can I make TextView scroll vertically?
Add the following sentence to the Java code to implement vertical scrolling.
[Java]
TextView. setMovementMethod (ScrollingMovementMethod. getInstance ());

 


From the column of zookeeper

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.