Android TextView

一、TextView不用获取焦点也能实现跑马灯

public class MarqueeTextView extends TextView {android

@Override  ide

    protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {  spa

        if(focused)  .net

            super.onFocusChanged(focused, direction, previouslyFocusedRect);  3d

    }  orm

    @Override  blog

    public void onWindowFocusChanged(boolean focused) {  游戏

        if(focused)  事件

            super.onWindowFocusChanged(focused);  ip

    }  

    @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"

这里解决了:一、下拉状态栏到半截不松开时和失去焦点时显示"......"的问题

                     二、失去焦点不滚动问题。


原文地址:http://blog.csdn.net/wangjia55/article/details/7867437 

二、上下行间距:

android:lineSpacingExtra="3dp"  //设置行间距

android:lineSpacingMultiplier="1.2"  // 设置行间距的倍数,如”1.2″。

左右字间距:

android:scaleX="3"

三、设置TextView下划线并响应点击事件(SpannableString)

http://blog.csdn.net/herbert5069/article/details/24587085 

http://aichixihongshi.iteye.com/blog/1207503  (很全面)

四、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个字符会出现问题。

相关文章
相关标签/搜索