package com.tikkrr.customViews;
import android.content.Context; import android.graphics.Canvas; import android.graphics.Color;
import android.graphics.Paint; import android.graphics.Rect; import android.util.AttributeSet;
import android.widget.EditText;
public class CustomTextView extends EditText{
private Rect mRect; private Paint mPaint; int widthMsSize; int heightMsSize ; // we need this constructor for LayoutInflater public CustomTextView(Context context, AttributeSet attrs) {
super(context, attrs); mPaint = new Paint();
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeWidth(2); mPaint.setColor(Color.RED);
System.out.println("constructor");
}
public void setUnderlineColor(int colorCode){
mPaint.setColor(colorCode);
}
protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec){
// Extract the Ms (MesaureSpec) parameters
widthMsSize = MeasureSpec.getSize(widthMeasureSpec);
heightMsSize = MeasureSpec.getSize(heightMeasureSpec);
System.out.println("on measure"); // Satisfy contract by calling setMeasuredDimension
setMeasuredDimension(widthMsSize, heightMsSize); } protected void onDraw(Canvas canvas) {
canvas.drawLine(5, heightMsSize, widthMsSize, heightMsSize, mPaint);
//draw underline super.onDraw(canvas); }
}