Android TextView實(shí)現(xiàn)垂直滾動效果的方法
本文實(shí)例講述了Android TextView實(shí)現(xiàn)垂直滾動效果的方法。分享給大家供大家參考,具體如下:
在TextView中,如果文本很長,可能需要實(shí)現(xiàn)垂直滾動顯示文本的效果。這里需要在XML布局文件中為TextView設(shè)置如下幾個(gè)屬性。
Android:scrollbars="vertical" android:scrollbarStyle="X"
其中X為outsideOverlay或insideOverlay。
android:scrollbarFadeDuration="X"
其中X表示滾動條從出現(xiàn)到消失的時(shí)間,單位是毫秒。
下面是一個(gè)完整的XML代碼例子。
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:id="@+id/textview" android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="false" android:maxLines="8" android:background="#FFF" android:textColor="#000" android:textSize="20dp" android:layout_margin="10dp" android:scrollbars="vertical" android:text="@string/big_text" android:scrollbarStyle="outsideOverlay" android:padding="10dp" android:scrollbarFadeDuration="2000" /> </LinearLayout>
運(yùn)行效果如下圖。
更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android滾動條與滾動操作技巧總結(jié)》、《Android圖形與圖像處理技巧總結(jié)》、《Android開發(fā)入門與進(jìn)階教程》、《Android調(diào)試技巧與常見問題解決方法匯總》、《Android多媒體操作技巧匯總(音頻,視頻,錄音等)》、《Android基本組件用法總結(jié)》、《Android視圖View技巧總結(jié)》、《Android布局layout技巧總結(jié)》及《Android控件用法總結(jié)》
希望本文所述對大家Android程序設(shè)計(jì)有所幫助。
- Android實(shí)現(xiàn)在TextView文字過長時(shí)省略部分或滾動顯示的方法
- android實(shí)現(xiàn)上下滾動的TextView
- android TextView不用ScrollViewe也可以滾動的方法
- Android中TextView實(shí)現(xiàn)垂直滾動和上下滾動效果
- Android編程實(shí)現(xiàn)TextView垂直自動滾動功能【附demo源碼下載】
- Android TextView 字體滾動效果
- Android中TextView實(shí)現(xiàn)超過固定行數(shù)顯示“...展開全部”
- Android TextView顯示html樣式的文字
- Android實(shí)現(xiàn)TextView顯示HTML加圖片的方法
- Android開發(fā)實(shí)現(xiàn)TextView顯示豐富的文本
- Android DrawableTextView圖片文字居中顯示實(shí)例
- Android開發(fā)中TextView文本過長滾動顯示實(shí)現(xiàn)方法分析
相關(guān)文章
Android使用ViewDragHelper實(shí)現(xiàn)QQ聊天氣泡拖動效果
這篇文章主要為大家詳細(xì)介紹了Android使用ViewDragHelper實(shí)現(xiàn)QQ聊天氣泡拖動效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-01-01Android編程實(shí)現(xiàn)播放音頻的方法示例
這篇文章主要介紹了Android編程實(shí)現(xiàn)播放音頻的方法,結(jié)合實(shí)例形式分析了Android使用MediaPlayer類播放音頻的相關(guān)操作技巧,需要的朋友可以參考下2017-08-08Kotlin中內(nèi)置函數(shù)的用法和區(qū)別總結(jié)
眾所周知相比Java, Kotlin提供了不少高級語法特性。對于一個(gè)Kotlin的初學(xué)者來說經(jīng)常會寫出一些不夠優(yōu)雅的代碼。下面這篇文章主要給大家介紹了關(guān)于Kotlin中內(nèi)置函數(shù)的用法和區(qū)別的相關(guān)資料,需要的朋友可以參考下2018-06-06Android編程實(shí)現(xiàn)使用Intent傳輸包含自定義類的ArrayList示例
這篇文章主要介紹了Android編程實(shí)現(xiàn)使用Intent傳輸包含自定義類的ArrayList,涉及Android對象序列化、反序列化、Intent數(shù)據(jù)傳輸?shù)认嚓P(guān)操作技巧,需要的朋友可以參考下2017-08-08