Android TextView Marquee的應(yīng)用實(shí)例詳解
Android TextView Marquee的應(yīng)用實(shí)例詳解
親測(cè)可能。直接上代碼。
Xml代碼
<TextView android:id="@+id/toolbar_title" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:fadingEdge="none" android:focusable="true" android:focusableInTouchMode="true" android:freezesText="true" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:singleLine="true" android:scrollHorizontally="true" android:textColor="#fff" android:textSize="16sp" />
mToolbarTitle.setSelected(true);
說(shuō)明:
XML 中以下幾行是必須的:
android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:singleLine="true"
最后別忘了,JAVA 中還需要調(diào)用 TextView 的 setSelected(true) 方法。
特別注意:
目前發(fā)現(xiàn),android:singleLine="true" 這種寫法需要已經(jīng)被廢棄了,但是目前只能這么寫 Marquee 才能生效。如果換成最新的寫法 android:maxLines="1",你會(huì)發(fā)現(xiàn),Marquee 并不能滾動(dòng)。不知道為什么。如果有知道原因的,或者有更好的寫法的,
以上就是Android TextView Marquee的實(shí)例詳解,如有疑問(wèn)請(qǐng)留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
相關(guān)文章
Android安裝apk文件并適配Android 7.0詳解
這篇文章主要介紹了Android安裝apk文件并適配Android 7.0詳解的相關(guān)資料,需要的朋友可以參考下2017-05-05
Android貝塞爾曲線實(shí)現(xiàn)直播點(diǎn)贊效果
這篇文章主要為大家詳細(xì)介紹了Android貝塞爾曲線實(shí)現(xiàn)直播點(diǎn)贊效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-03-03
android 關(guān)于webview 加載h5網(wǎng)頁(yè)開啟定位的方法
今天小編就為大家分享一篇android 關(guān)于webview 加載h5網(wǎng)頁(yè)開啟定位的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-07-07
Android自定義ViewGroup之實(shí)現(xiàn)FlowLayout流式布局
這篇文章主要為大家詳細(xì)介紹了Android自定義ViewGroup之實(shí)現(xiàn)FlowLayout流式布局的相關(guān)代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-06-06
Android?APP啟動(dòng)時(shí)間優(yōu)化介紹
大家好,本篇文章主要講的是Android?APP啟動(dòng)時(shí)間優(yōu)化介紹,感興趣的同學(xué)趕快來(lái)看一看吧,對(duì)你有幫助的話記得收藏一下,方便下次瀏覽2021-12-12
Android實(shí)現(xiàn)創(chuàng)建或升級(jí)數(shù)據(jù)庫(kù)時(shí)執(zhí)行語(yǔ)句
這篇文章主要介紹了Android實(shí)現(xiàn)創(chuàng)建或升級(jí)數(shù)據(jù)庫(kù)時(shí)執(zhí)行語(yǔ)句,是比較實(shí)用的功能,需要的朋友可以參考下2014-08-08
Android進(jìn)度條ProgressBar的實(shí)現(xiàn)代碼
這篇文章主要為大家詳細(xì)介紹了Android進(jìn)度條ProgressBar的實(shí)現(xiàn)代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-09-09

