---
title: "不用获得焦点也能实现跑马灯效果的textView"
author: "runfeel"
date: "2011-10-26T15:34:00Z"
tags: []
slug: "textview"
draft: false
lastmod: "2013-07-11T13:40:07Z"
id: 1903699
url: "https://runfeel.iteye.com/blog/1903699"
---

```
/**
 * 这是一个不用获得焦点也能实现跑马灯效果的textView
 * @author Chenzt
 *
 */
public class MarqueeTextView extends TextView {
	public MarqueeTextView(Context con) {
		super(con);
	}

	public MarqueeTextView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public MarqueeTextView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	@Override
	public boolean isFocused() {
		return true;
	}

	@Override
	protected void onFocusChanged(boolean focused, int direction,
			Rect previouslyFocusedRect) {
	}
}
```