android: 不需要焦點的TextView跑馬燈 MarqueeTextView


原文地址


public class MarqueeTextView extends TextView {

	public MarqueeTextView(Context appCon) {
		super(appCon);
	}

	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) {
	}
}

下面就是如何使用跑馬燈的XML

<com.lta.mytransport.ui.utils.MarqueeTextView android:id="@+id/floodMsgView"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:layout_weight="1"
			android:ellipsize="marquee"
			android:singleLine="true"
			android:focusable="true"
			android:focusableInTouchMode="true"
			android:freezesText="true"
			android:scrollHorizontally="true"
			android:text="@string/floodMsgDemo"
			android:marqueeRepeatLimit="marquee_forever"/>



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章