对于textview及其子类,当文字显示不下时目前有四种显示效果。在显示区域的起始,中间,结束位置以省略号表示,或者以跑马灯的方式显示文字(textview的状态为被选中)。
其实现只需在xml中对textview的ellipsize属性做相应的设置即可。 各item如下: android:ellipsize="start" 省略号在开头 android:ellipsize="middle" 省略号在中间 android:ellipsize="end" 省略号在结尾 android:ellipsize="marquee" 跑马灯显示 或者在程序中可通过setEillpsize显式设置。 另:需要注意的是edittext不支持marquee这种模式。 我在使用TextView.ellipsize="marquee"属性,跑马灯效果: 我用如下代码申明TextView对象: <TextView xmlns:a="http://schemas./apk/res/android" a:layout_width="fill_parent" a:layout_height="fill_parent" a:textSize="22px" a:ellipsize="marquee" a:singleLine="true" a:marqueeRepeatLimit="marquee_forever" a:focusable="true" a:text="Simple application that shows how to use RelativeLayout"> </TextView> 其中与Marquee相关的几个属性我用亮兰色标示出来.TextView获得焦点后,马灯才能跑起来 |
|
来自: shaobin0604@1... > 《Android》