`
ET焖猪仔
  • 浏览: 233360 次
  • 性别: Icon_minigender_1
  • 来自: 广东
社区版块
存档分类
最新评论

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"  
/>   
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics