Created
August 29, 2012 03:53
-
-
Save jiemachina/3506634 to your computer and use it in GitHub Desktop.
Marquee TextView 跑马灯效果
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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