Skip to content

Instantly share code, notes, and snippets.

@jiemachina
Created August 29, 2012 03:53
Show Gist options
  • Save jiemachina/3506634 to your computer and use it in GitHub Desktop.
Save jiemachina/3506634 to your computer and use it in GitHub Desktop.
Marquee TextView 跑马灯效果
package jie.ma.china.view;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.TextView;
public class MyTextView extends TextView {
public MyTextView(Context context) {
this(context, null);
}
public MyTextView(Context context, AttributeSet attrs) {
this(context, attrs, android.R.attr.textViewStyle);
}
public MyTextView(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onFocusChanged(boolean focused, int direction,
Rect previouslyFocusedRect) {
if (focused)
super.onFocusChanged(focused, direction, previouslyFocusedRect);
}
@Override
public void onWindowFocusChanged(boolean focused) {
if (focused)
super.onWindowFocusChanged(focused);
}
@Override
public boolean isFocused() {
return true;
}
}
android:ellipsize="marquee"
android:singleLine="true"
android:marqueeRepeatLimit="marquee_forever"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment