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) 方法。
特別注意:
目前發現,android:singleLine="true" 這種寫法需要已經被廢棄了,但是目前只能這么寫 Marquee 才能生效。如果換成最新的寫法 android:maxLines="1",你會發現,Marquee 并不能滾動。不知道為什么。如果有知道原因的,或者有更好的寫法的,
以上就是Android TextView Marquee的實例詳解,如有疑問請留言或者到本站社區交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。