自定义TextView显示偏移问题
先上最终要实现的效果图好了:
下面上代码:`public class MyTextView extends TextView {
private String titleText;
private int titleColor;
private int titleSize;
private Rect mBound;
private Paint mPaint;
public MyTextView(Context context) {
this(context,null);
}
public MyTextView(Context context,AttributeSet attrs){
this(context,attrs,0);
}
public MyTextView(Context context,AttributeSet attrs,int defStyle){
super(context,attrs,defStyle);
TypedArray ta = context.getTheme().obtainStyledAttributes(attrs, R.styleable.MyTextView, defStyle, 0);
int n=ta.getIndexCount();//得到属性个数
for(int i=0;i<n;i++) {
int attr = ta.getIndex(i);//属性对应的下标
switch (attr) {
case R.styleable.MyTextView_titleText: