Recently in writing their own first app, the process encountered this problem, check a lot of posts, after trying to find that this problem is generally divided into two categories:
1. TextView text value is not changed after assignment, many of the posts said the following wording can be effective:
<TextViewAndroid:id= "@+id/music_name_tv"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"android:ellipsize= "marquee" "must"android:focusable= "true" "must"Android:focusableintouchmode= "true" "must"Android:lines= "1" "must"Android:text= " My Chinese Heart my Chinese heart my Chinese heart my Chinese heart my Chinese heart my Chinese heart my China heart My Chinese Heart my Chinese HeartAndroid:textcolor= "@color/coloraccent"android:textsize= "15SP" />
2. TextView text dynamic assignment, this time directly written in the layout of the XML is not effective, you need to assign a value to TextView, and then re-set the property in the code again:
Public Static void Settextmarquee (TextView TextView) { ifnull) { textview.setellipsize ( TextUtils.TruncateAt.MARQUEE); Textview.setsingleline (true); Textview.setselected (true); Textview.setfocusable (true); Textview.setfocusableintouchmode (true); } }
Note:
1. The first case has been tested, not on my phone, even if the TextView is not dynamically assigned, still cannot scroll, guess should be system compatibility problem.
2. The second type of validation is OK, and the direct code assignment is recommended.
TextView attribute android:ellipsize= "marquee" does not take effect for the workaround