溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Android TextView Marquee的應用實例詳解

發布時間:2020-09-04 20:47:11 來源:腳本之家 閱讀:259 作者:yhz61010 欄目:移動開發

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的實例詳解,如有疑問請留言或者到本站社區交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女