---
title: "Android TextView跑马灯效果代码"
author: "小建枫叶"
date: "2012-04-18T12:36:25Z"
tags: []
categories: ["移动开发"]
slug: "android-textview"
draft: false
lastmod: "2012-04-18T12:41:08Z"
id: 1489306
url: "https://smallmaple.iteye.com/blog/1489306"
---

实现TextView文字滚动效果（跑马灯）只需要在TextView中多设置一些属性就可以了。具体看代码：

 

```
<TextView
        android:id="@+id/main_more_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:text=" Android TextView跑马灯效果代码                                   "
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="#FF00FF"

        android:ellipsize="marquee" 
        android:singleLine="true"
        android:marqueeRepeatLimit="marquee_forever" 
        android:focusable="true" 
        android:focusableInTouchMode="true" 
        android:scrollHorizontally="true"
      
        />
```

 最重要的是后面六行代码，还有个地方就是TextView的文字要足够长，不够可以用空格补充！