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 中還需要調(diào)用 TextView 的 setSelected(true) 方法。
特別注意:
目前發(fā)現(xiàn),android:singleLine="true" 這種寫法需要已經(jīng)被廢棄了,但是目前只能這么寫 Marquee 才能生效。如果換成最新的寫法 android:maxLines="1",你會發(fā)現(xiàn),Marquee 并不能滾動。不知道為什么。如果有知道原因的,或者有更好的寫法的,
以上就是Android TextView Marquee的實例詳解,如有疑問請留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關(guān)文章
Android實現(xiàn)基于滑動的SQLite數(shù)據(jù)分頁加載技術(shù)(附demo源碼下載)
這篇文章主要介紹了Android實現(xiàn)基于滑動的SQLite數(shù)據(jù)分頁加載技術(shù),涉及Android針對SQLite數(shù)據(jù)的讀取及查詢結(jié)果的分頁顯示功能相關(guān)實現(xiàn)技巧,末尾還附帶demo源碼供讀者下載參考,需要的朋友可以參考下2016-07-07淺談Android應用安全防護和逆向分析之a(chǎn)pk反編譯
我們有時候在某個app上見到某個功能,某個效果蠻不錯的,我們想看看對方的思路怎么走的,這時候,我們就可以通過反編譯來編譯該apk,拿到代碼,進行分析。2021-06-06Android 仿微信自定義數(shù)字鍵盤的實現(xiàn)代碼
本篇文章主要介紹了Android 仿微信自定義數(shù)字鍵盤的實現(xiàn)代碼,具有一定的參考價值,有興趣的可以了解一下2017-07-07