2019独角兽企业重金招聘Python工程师标准>>>
1、TextView不用获取焦点也能实现跑马灯
public class MarqueeTextView extends TextView {
@Override
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
if(focused)
super.onFocusChanged(focused, direction, previouslyFocusedRect);
}
@Override
public void onWindowFocusChanged(boolean focused) {
if(focused)
super.onWindowFocusChanged(focused);
}
@Override
public boolean isFocused() {
return true;
}
}
android:singleLine="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:ellipsize="marquee"
android:scrollHorizontally="true"
android:marqueeRepeatLimit="marquee_forever"
这里解决了:1、下拉状态栏到半截不松开时和失去焦点时显示"......"的问题
2、失去焦点不滚动问题。
原文地址:http://blog.csdn.net/wangjia55/article/details/7867437
2、上下行间距:
android:lineSpacingExtra="3dp" //设置行间距
android:lineSpacingMultiplier="1.2" // 设置行间距的倍数,如”1.2″。
左右字间距:
android:scaleX="3"
3、设置TextView下划线并响应点击事件(SpannableString)
http://blog.csdn.net/herbert5069/article/details/24587085
http://aichixihongshi.iteye.com/blog/1207503 (很全面)
4、TextView设置最多显示8个字符,超过部分显示...(省略号)
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="安德的游戏安德的游戏安德的游戏"
android:ellipsize="end"
android:singleLine="true"
android:maxEms="8"/>
如果加上android:paddingLeft="20dp",此时所限制的8个字符会出现问题。