你的分享就是我们的动力 ---﹥

android TextView 跑马灯效果

时间:2013-05-16 16:49来源:www.chengxuyuans.com 点击:

代码简介

重写TextView的isFocused()方法,让他一直返回true。

代码片段

package com.android.sojiaju.util;

import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.TextView;

public class FTextView extends TextView {

	public FTextView(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
	}

	public FTextView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		// TODO Auto-generated constructor stub
	}

	public FTextView(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
	}

	@Override
	public boolean isFocused() {
		// 返回true 这样才能实现滚动
		return true;
	}
	@Override
	protected void onFocusChanged(boolean focused, int direction,
			Rect previouslyFocusedRect) {
		// TODO Auto-generated method stub
		super.onFocusChanged(focused, direction, previouslyFocusedRect);
	}
}

转载注明地址http://www.chengxuyuans.com/code/java/60581.html