android中設(shè)置TextView/Button 走馬燈(Marquee)效果示例
更新時(shí)間:2013年06月19日 15:33:23 作者:
定義走馬燈(Marquee),主要在Project/res/layout/main.xml即可,下面與大家分享下具體的實(shí)現(xiàn),感興趣的朋友可以參考下哈
在Android的ApiDemo中,有Button的走馬燈效果,但是換作是TextView,還是有一點(diǎn)差異。
定義走馬燈(Marquee),主要在Project/res/layout/main.xml即可
<SPAN style="COLOR: #993300"><TextView
android:layout_width="40px"
android:layout_height="wrap_content"
android:text="Test marquee for TextView"
android:layout_gravity="center"
android:ellipsize="marquee"
android:singleLine="true"
android:focusable="true"
android:marqueeRepeatLimit="marquee_forever"
android:focusableInTouchMode="true"
android:scrollHorizontally="true"
/></SPAN>
關(guān)鍵點(diǎn):
(1)layout_width設(shè)定的長度要比text其實(shí)的長度短才行,即layout_width顯示不全text才會(huì)有走馬燈效果 (2)ellipsize 即申明使用走馬燈marquee
(3)singleLine表示單行顯示
(4)marqueeRepeatLimit表示走馬燈顯示的次數(shù):marquee_forever-無限制不間斷顯示
<SPAN style="COLOR: #993300"><Button
android:id="@+id/buttonMarquee"
android:layout_width="320px"
android:layout_height="wrap_content"
android:text="@string/textMarquee"
android:singleLine="true"
android:focusable="true"
android:selectAllOnFocus="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
/></SPAN>
其中@string/textMarquee為/res/valuse/strings.xml定義的字符串
定義走馬燈(Marquee),主要在Project/res/layout/main.xml即可
復(fù)制代碼 代碼如下:
<SPAN style="COLOR: #993300"><TextView
android:layout_width="40px"
android:layout_height="wrap_content"
android:text="Test marquee for TextView"
android:layout_gravity="center"
android:ellipsize="marquee"
android:singleLine="true"
android:focusable="true"
android:marqueeRepeatLimit="marquee_forever"
android:focusableInTouchMode="true"
android:scrollHorizontally="true"
/></SPAN>
關(guān)鍵點(diǎn):
(1)layout_width設(shè)定的長度要比text其實(shí)的長度短才行,即layout_width顯示不全text才會(huì)有走馬燈效果 (2)ellipsize 即申明使用走馬燈marquee
(3)singleLine表示單行顯示
(4)marqueeRepeatLimit表示走馬燈顯示的次數(shù):marquee_forever-無限制不間斷顯示
復(fù)制代碼 代碼如下:
<SPAN style="COLOR: #993300"><Button
android:id="@+id/buttonMarquee"
android:layout_width="320px"
android:layout_height="wrap_content"
android:text="@string/textMarquee"
android:singleLine="true"
android:focusable="true"
android:selectAllOnFocus="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
/></SPAN>
其中@string/textMarquee為/res/valuse/strings.xml定義的字符串
相關(guān)文章
Android解決dialog彈出時(shí)無法捕捉Activity的back事件的方法
這篇文章主要介紹了Android解決dialog彈出時(shí)無法捕捉Activity的back事件的方法,涉及Android操作Activity事件的相關(guān)技巧,需要的朋友可以參考下2015-05-05android使用include調(diào)用內(nèi)部組件的方法
這篇文章主要介紹了android使用include調(diào)用內(nèi)部組件的方法,涉及Android組件調(diào)用的相關(guān)技巧,需要的朋友可以參考下2015-05-05Android實(shí)現(xiàn)ListView控件的多選和全選功能實(shí)例
這篇文章主要介紹了Android實(shí)現(xiàn)ListView控件的多選和全選功能,結(jié)合實(shí)例形式分析了ListView控件多選及全選功能的布局與功能實(shí)現(xiàn)技巧,需要的朋友可以參考下2017-07-07Android GPS獲取當(dāng)前經(jīng)緯度坐標(biāo)
這篇文章主要為大家詳細(xì)介紹了Android GPS獲取當(dāng)前經(jīng)緯度坐標(biāo),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-05-05基于Fedora14下自帶jdk1.6版本 安裝jdk1.7不識(shí)別的解決方法
本篇文章是對(duì)Fedora14下自帶jdk1.6版本,安裝jdk1.7不識(shí)別的解決方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-05-05