android中TextView实现跑马灯效果

亲测,废话不多说,很简单,直接上代码:

      android:ellipsize="marquee"    //表示是跑马灯显示
            android:focusable="true"       //要显示该跑马灯,view必须要获得焦点,只有在取得焦点的情况下跑马灯才会显示
            android:focusableInTouchMode="true"   //通过touch来获得focus
            android:marqueeRepeatLimit="marquee_forever"   //表示滚动回数,这里这么设置,表示一直滚动
            android:maxEms="6"        //设置TextView的宽度为最长为N个字符的宽度
            android:scrollHorizontally="true"    //设置文本超出TextView的宽度的情况下,是否出现横拉条。
            android:singleLine="true"     //单行显示

猜你喜欢

转载自blog.csdn.net/qq_23934247/article/details/53421845