下拉框如何做跑马灯效果

今天看了一下spinner的实现,

发现用的是textview.那做跑马灯应该也是可以的.

于是在网上找了一下相关的代码.

先写一个类.就是继承TextView的类

public class AlwaysMarqueeTextView extends TextView {

	public AlwaysMarqueeTextView(Context context) {
		super(context);
	}

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

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

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

  XML文件

<com.cn.AlwaysMarqueeTextView
    android:layout_width=“fill_parent”
    android:layout_height=“wrap_content”
    android:lines=“1″
    android:focusable=“true”
    android:focusableInTouchMode=“true”
    android:scrollHorizontally=“true”
    android:marqueeRepeatLimit=“marquee_forever”
    android:ellipsize=“marquee”
/>

  这个样,下拉框选中的值也可以有跑马灯的效果了.

posted on 2012-12-25 19:17  古都小新  阅读(208)  评论(0)    收藏  举报