首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

TextView兑现跑马灯效果

2012-09-20 
TextView实现跑马灯效果TextView vnew TextView(this)v.setText(哇哈哈哇哈哈哇哈哈哇哈哈哇哈哈wahaha

TextView实现跑马灯效果

  TextView v=new TextView(this);                        v.setText("哇哈哈哇哈哈哇哈哈哇哈哈哇哈哈wahahawahhahwahhahahwahahhahahawhahhaha......");        v.setTransformationMethod(SingleLineTransformationMethod.getInstance());        v.setSingleLine(true);        v.setEllipsize(TruncateAt.MARQUEE);        v.setMarqueeRepeatLimit(3);        setContentView(v);                v.setFocusable(true);


或者在xml文件中声明
<TextView       android:id="@+id/text"      android:layout_width="100px"      android:layout_height="wrap_content"                         //居中显示       android:layout_centerInParent="true"                         //使得字不分行显示 否则当字太多会分行       android:singleLine="true"             android:layout_x="61px"      android:layout_y="69px"                    //设置为"滚动"       android:ellipsize="marquee"                                     //设置滚动时间为永远 也可以为具体的int 来设置滚动次数       android:marqueeRepeatLimit="marquee_forever"  />   

热点排行