本篇文章為大家展示了在Android中使用TextView實(shí)現(xiàn)一個跑馬燈效果,內(nèi)容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細(xì)介紹希望你能有所收獲。
條件:
1、android:ellipsize=”marquee”
2、TextView必須單行顯示,即內(nèi)容必須超出TextView大小
3、TextView要獲得焦點(diǎn)才能滾動
mTVText.setText(“超過文本長度的數(shù)據(jù)");
mTVText.setSingleLine(true);設(shè)置單行顯示
mTVText.setEllipsize(TruncateAt.MARQUEE);設(shè)置跑馬燈顯示效果
TextView.setHorizontallyScrolling(true); //讓文字可以水平滑動
TextView還可以設(shè)置跑馬燈效果的滾動次數(shù)
android:marqueerepeatlimit="1"。1代表1次,-1代表無限循環(huán)。
Java代碼設(shè)置:
mTVText.setMarqueeRepeatLimit(-1);
.xml文件:
<TextView android:id="@+id/tv_marquee" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/tv_marquee_text" android:textSize="25sp" android:focusable="true" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:focusableInTouchMode="true" android:textColor="@color/colorPrimary" />
網(wǎng)頁題目:在Android中使用TextView實(shí)現(xiàn)一個跑馬燈效果-創(chuàng)新互聯(lián)
當(dāng)前URL:http://vcdvsql.cn/article4/jejoe.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航、響應(yīng)式網(wǎng)站、網(wǎng)站營銷、云服務(wù)器、企業(yè)網(wǎng)站制作、品牌網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容