[Android1.5]TextView跑馬燈效果

來源:互聯網
上載者:User

前言

  這個效果在兩周前搜尋過,網上倒是有轉載,可恨的是轉載之後本人有測試過?!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為自訂控制項,大家可以參考一下。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.