美文网首页
2019-06-27 Android TextView实现跑马灯

2019-06-27 Android TextView实现跑马灯

作者: Yangxy_Lazy | 来源:发表于2019-06-27 10:12 被阅读0次

一、使用限制

  • 一个页面上只能有一个跑马灯效果

    //使用方法:加入以下属性
                          android:singleLine="true"
                android:ellipsize="marquee"
                android:focusableInTouchMode="true"
                android:focusable="true"
    

二、若要是的多个TextView同时实现跑马灯效果,则需要重写isFocused方法

  ① override fun isFocused(): Boolean {
        return true
    }

  ②再在布局文件中加入:
            android:singleLine="true"
            android:ellipsize="marquee"
            android:focusableInTouchMode="true"
            android:focusable="true"
              
  ③android:marqueeRepeatLimit="marquee_forever" 这个属性是设置无限重复,如果不设置的话,默认会在3次之后停止不动了            

相关文章

网友评论

      本文标题:2019-06-27 Android TextView实现跑马灯

      本文链接:https://www.haomeiwen.com/subject/bdrlcctx.html