1,XML布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.eduask.demo3.ui.UiTextView
android:marqueeRepeatLimit="marquee_forever"
android:ellipsize="marquee"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="@string/hello_world" />
</RelativeLayout>

2,Java代码

public class UiTextView extends TextView {

public UiTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}

public UiTextView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}

public UiTextView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}

@Override
public boolean isFocused() {
// TODO Auto-generated method stub
return true;
}

}