package ddd.testdd.com;
1、重新封装了TextView
import android.content.Context;
import android.util.AttributeSet;
import android.widget.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;
}
}
2 在xml中调用
<?xml version="1.0" encoding="utf-8"?>
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ddd.testdd.com.alwaysmarqueetextview
android:text="哈哈我的跑马灯程序接下来是歌词呵呵:沉鱼落雁,闭月羞花"
android:focusableintouchmode="true" android:scrollhorizontally="true"
android:marqueerepeatlimit="marquee_forever" android:singleline="true"
android:focusable="true" android:ellipsize="marquee"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:gravity="center|clip_horizontal"/>
</linearlayout>