简体   繁体   中英

Show long text in short TextView?

How to create a TextView with a long text so that the text in this TextView is automatically reviewed and displayed from end to end like horizontal slides?

In fact, I want textview to scroll automatically and scroll again from the beginning after the text is finished.

The image is the output of my code, but I do not want this.

enter image description here

make ellipsize=marquee and singleLine=true within textView

I found the answer!
You must add these features to TextView:

android:ellipsize = "marquee"
android:fadingEdge = "horizontal"
android:marqueeRepeatLimit = "marquee_forever"
android:scrollHorizontally = "true"
android:singleLine = "true"

then:

TextView txt = findViewById(R.id.text); txt.setSelected(true);

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM