Android TextView Marquee的應用實例詳解
Android TextView Marquee的應用實例詳解
親測可能。直接上代碼。
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);
說明:
XML 中以下幾行是必須的:
android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:singleLine="true"
最后別忘了,JAVA 中還需要調用 TextView 的 setSelected(true) 方法。
特別注意:
目前發(fā)現(xiàn),android:singleLine="true" 這種寫法需要已經(jīng)被廢棄了,但是目前只能這么寫 Marquee 才能生效。如果換成最新的寫法 android:maxLines="1",你會發(fā)現(xiàn),Marquee 并不能滾動。不知道為什么。如果有知道原因的,或者有更好的寫法的,
以上就是Android TextView Marquee的實例詳解,如有疑問請留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關文章
Android安裝apk文件并適配Android 7.0詳解
這篇文章主要介紹了Android安裝apk文件并適配Android 7.0詳解的相關資料,需要的朋友可以參考下2017-05-05
android 關于webview 加載h5網(wǎng)頁開啟定位的方法
今天小編就為大家分享一篇android 關于webview 加載h5網(wǎng)頁開啟定位的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-07-07
Android自定義ViewGroup之實現(xiàn)FlowLayout流式布局
這篇文章主要為大家詳細介紹了Android自定義ViewGroup之實現(xiàn)FlowLayout流式布局的相關代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-06-06
Android實現(xiàn)創(chuàng)建或升級數(shù)據(jù)庫時執(zhí)行語句
這篇文章主要介紹了Android實現(xiàn)創(chuàng)建或升級數(shù)據(jù)庫時執(zhí)行語句,是比較實用的功能,需要的朋友可以參考下2014-08-08
Android進度條ProgressBar的實現(xiàn)代碼
這篇文章主要為大家詳細介紹了Android進度條ProgressBar的實現(xiàn)代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-09-09

