TextView and textview
Reprinted: http://www.2cto.com/kf/201409/330658.html
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
android:singleLine="true" android:ellipsize="start"
Show ellipsis at the end
android:singleLine="true" android:ellipsize="end"
Show ellipsis in the middle
android:singleLine="true" android:ellipsize="middle"
Automatic horizontal scrolling (running horse light effect)
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: textView. setMovementMethod (ScrollingMovementMethod. getInstance ());
3. How can I change the content of TextView?
Override TextView to keep TextView selected: AlwaysMarqueeTextView. java
/** Override TextView to ensure that the running horse lights remain displayed */public class AlwaysMarqueeTextView extends TextView {public AlwaysMarqueeTextView (Context context) {super (context);} public AlwaysMarqueeTextView (Context context, AttributeSet attrs) {super (context, attrs);} public AlwaysMarqueeTextView (Context context, AttributeSet attrs, int defStyle) {super (context, attrs, defStyle);} @ Override public boolean isFocused () {return true; // be sure to set it to true }}