非常之簡單

 

<TextView android:id="@+id/map_view_textview"
android:layout_width="100dip"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"

android:gravity="center"
android:layout_height="wrap_content"
android:text="This is a Test TextView" /><requestFocus/>

 

紅色的都是重點

android:layout_width 因為你要給他寬度 他才能在你設的寬度裡 如果文字內容超過寬度 則會實現跑馬燈

以下5行照抄就對了

android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"

 

還有結尾一定要加<requestFocus/> 這樣他才能動態顯示喔 不然有時候會停住

而且最好TextView放在xml所有元件裡面最上面一個


arrow
arrow
    文章標籤
    android TextView 跑馬燈
    全站熱搜

    cookiesp 發表在 痞客邦 留言(0) 人氣()