歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Android:TextView跑馬燈詳解

Android:TextView跑馬燈詳解

日期:2017/3/1 9:48:48   编辑:Linux編程

引言:

TextView之所以需要跑馬燈,是由於文字太長,或者是吸引眼球。

關鍵代碼如下:

Android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:marqueeRepeatLimit="marquee_forever"
android:focusableInTouchMode="true"
android:scrollHorizontally="true"

屬性詳解:

還有兩個函數由於在Android開發手冊中沒有找到,但是從字面上可以看出

android:focusable="true"

是指出在得到焦點後觸發事件。

android:focusableInTouchMode="true"

是指不用撈取焦點,就觸發事件。也就是説一運行,就觸點該事件。

android:singleLine="true"

是設置TextView只顯示一行

實例

<TextView
android:id="@+id/horseRace Lamp"
android:layout_width="fill_parent" android:layout_height="wrap_content"

android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:marqueeRepeatLimit="marquee_forever"
android:focusableInTouchMode="true"
android:scrollHorizontally="true"
android:text="Welcom to FDA-orangebook's blogs"
/>

復制去Google翻譯翻譯結果

機器人:focusableInTouchMode=“真”

更多Android相關信息見Android 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=11

Copyright © Linux教程網 All Rights Reserved