方式一 :
布局中定义:
image.png
代码中
image.png
方式二:
创建一个类:
继承TextView
···
package com.example.progress;
import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.widget.TextView;
/**
- Created by lenovo on 2018/8/17.
*/
public class MYTextview extends android.support.v7.widget.AppCompatTextView{
public MYTextview(Context context) {
super(context);
}
public MYTextview(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public MYTextview(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public boolean isFocused() {
return true;//获取焦点
}
}
···
布局中
image.png