跑马灯简单实现

先发布一下布局效果

<TextView
        android:id="@+id/tv_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ellipsize="marquee"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:marqueeRepeatLimit="marquee_forever"
        android:singleLine="true"
        android:textSize="28sp"
        android:text="路漫漫其修远兮,吾将上下而求索3w3erweqrwqreqwreqwerwqrwrq"
        android:textColor="#00ff00"
        android:scrollHorizontally="true"/>

Activity的主要实现

//设置为跑马灯显示
 android:ellipsize="marquee"
 
//获取焦点
 android:focusable="true"
 
  //可以通过toucth来获得focus
android:focusableInTouchMode="true"

  //设置重复的次数
  android:marqueeRepeatLimit="marquee_forever"
 
 //单行显示文字
 android:singleLine="true"
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章