---
title: "Android TextView实现跑马灯效果_1_1"
author: "daoshud1"
date: "2015-01-07T21:24:13Z"
tags: []
categories: ["移动开发"]
slug: "android-textview-1-1"
draft: false
lastmod: "2015-01-07T21:37:54Z"
id: 2173697
url: "https://daoshud1.iteye.com/blog/2173697"
---

在安卓开发过程中，经常会有TextView显示一行内容，但是超过了屏幕宽度 就会自动换行，如果给TextView增加

```java

android:singleLine="true"

```

属性的话，则会在一行显示，但是超过屏幕宽度的内容会以省略号的方式展示，如何才能在一行内显示，经百度、谷歌查阅增加以下属性就可以实现跑马灯的效果，并且可以在一行内展示出所有的内容：

```java

android:ellipsize="marquee"  //超宽后显示的省略号去除
//以下两项增加后，文字会在一行内实现跑马灯的效果
android:focusable="true" //代表TextView获得选中状态
android:focusableInTouchMode="true"

```