Android TextView實(shí)現(xiàn)垂直滾動(dòng)效果的方法
本文實(shí)例講述了Android TextView實(shí)現(xiàn)垂直滾動(dòng)效果的方法。分享給大家供大家參考,具體如下:
在TextView中,如果文本很長(zhǎng),可能需要實(shí)現(xiàn)垂直滾動(dòng)顯示文本的效果。這里需要在XML布局文件中為TextView設(shè)置如下幾個(gè)屬性。
Android:scrollbars="vertical" android:scrollbarStyle="X"
其中X為outsideOverlay或insideOverlay。
android:scrollbarFadeDuration="X"
其中X表示滾動(dòng)條從出現(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滾動(dòng)條與滾動(dòng)操作技巧總結(jié)》、《Android圖形與圖像處理技巧總結(jié)》、《Android開發(fā)入門與進(jìn)階教程》、《Android調(diào)試技巧與常見問題解決方法匯總》、《Android多媒體操作技巧匯總(音頻,視頻,錄音等)》、《Android基本組件用法總結(jié)》、《Android視圖View技巧總結(jié)》、《Android布局layout技巧總結(jié)》及《Android控件用法總結(jié)》
希望本文所述對(duì)大家Android程序設(shè)計(jì)有所幫助。
- Android實(shí)現(xiàn)在TextView文字過長(zhǎng)時(shí)省略部分或滾動(dòng)顯示的方法
- android實(shí)現(xiàn)上下滾動(dòng)的TextView
- android TextView不用ScrollViewe也可以滾動(dòng)的方法
- Android中TextView實(shí)現(xiàn)垂直滾動(dòng)和上下滾動(dòng)效果
- Android編程實(shí)現(xiàn)TextView垂直自動(dòng)滾動(dòng)功能【附demo源碼下載】
- Android TextView 字體滾動(dòng)效果
- 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文本過長(zhǎng)滾動(dòng)顯示實(shí)現(xiàn)方法分析
相關(guān)文章
Android 應(yīng)用Crash 后自動(dòng)重啟的方法小結(jié)
這篇文章主要介紹了Android 應(yīng)用Crash 后自動(dòng)重啟的方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-06-06
Android手機(jī)鬧鐘服務(wù)AlarmManagerk開發(fā)案例
這篇文章主要為大家詳細(xì)介紹了Android手機(jī)鬧鐘服務(wù)AlarmManagerk開發(fā)案例的資料,需要的朋友可以參考下2016-05-05
Android UI實(shí)時(shí)預(yù)覽和編寫的各種技巧
大家好,今天給大家分享的是Android中實(shí)時(shí)預(yù)覽UI和編寫UI的各種技巧,2015-11-11
Android nativePollOnce函數(shù)解析
這篇文章主要介紹了Android nativePollOnce函數(shù)解析的相關(guān)資料,幫助大家更好的理解和學(xué)習(xí)使用Android,感興趣的朋友可以了解下2021-03-03
Android基于API的Tabs3實(shí)現(xiàn)仿優(yōu)酷t(yī)abhost效果實(shí)例
這篇文章主要介紹了Android基于API的Tabs3實(shí)現(xiàn)仿優(yōu)酷t(yī)abhost效果,結(jié)合完整實(shí)例形式分析了Android實(shí)現(xiàn)優(yōu)酷界面效果的相關(guān)技巧,需要的朋友可以參考下2015-12-12

