一、布局文件中
<com.itheima.mobilesafe.ui.FocusedTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:ellipsize="marquee"
android:singleLine="true"
android:text="我是你的小黑马卫士,哈哈哈哈,我可以保护你的手机安全.嘎嘎嘎嘎" />
附加:Button控件
<Button
android:focusableInTouchMode="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:singleLine="true"
android:text="我是你的小黑马卫士,哈哈哈哈,我可以保护你的手机安全.嘎嘎嘎嘎" />
二、/src中定义自定义的控件
public class FocusedTextView extends TextView {
public FocusedTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public FocusedTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public FocusedTextView(Context context) {
super(context);
}
public boolean isFocused() {
return true;
}
}