前言
這個效果在兩周前搜尋過,網上倒是有轉載,可恨的是轉載之後本人有測試過?!N多人都在後面跟帖沒效果! 後來沒辦法臨時用定時器來刷的。
文章
1. Ellipsize not working for textView inside custom listView
2. ScrollTextView - scrolling TextView for Android
聲明
歡迎轉載,但請保留文章原始出處:)
部落格園:http://www.cnblogs.com
農民伯伯: http://www.cnblogs.com/over140/
本文
本文得益於文章1的提示,雖然沒全看明白,但是看見代碼就複製下來然後測試,果然給我撞出來了- - #。
一、
二、實現代碼:
<TextView android:layout_width="100px"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:ellipsize="marquee"
android:focusable="true"
android:marqueeRepeatLimit="marquee_forever"
android:focusableInTouchMode="true"
android:scrollHorizontally="true"
android:text="這才是真正的文字跑馬燈效果"
>
</TextView>
代碼說明:
a). 經測試與轉載文章區別主要在於這裡有設定android:focusableInTouchMode
b). 測試環境為Android1.5、模擬器。
三、後期維護
3.12013-07-01
本博後續文章:【Android】不依賴焦點和選中的TextView跑馬燈
結束
出來寫文章,即使是轉載也得負責。文章2為自訂控制項,大家可以參考一下。