package com.example.mountaintravel.view;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.DashPathEffect;
import android.graphics.Paint;
import android.graphics.PathEffect;
import android.util.AttributeSet;
import android.widget.EditText;

public class MyEdittext extends EditText {
	public MyEdittext(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
	}

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

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

	 @SuppressLint("NewApi") @Override
	protected void onDraw(Canvas canvas) {
		// TODO Auto-generated method stub
		Paint mPaint = new Paint();
		// mPaint.setColor(0x80000000);
		mPaint.setStyle(Paint.Style.STROKE);
		mPaint.setColor(Color.LTGRAY);
		PathEffect effects = new DashPathEffect(new float[] { 5, 5, 5, 5 }, 5);
		mPaint.setPathEffect(effects);

		int left = getLeft();
		int right = getRight();
		int paddingTop = getPaddingTop();
		int paddingBottom = getPaddingBottom();
		int paddingLeft = getPaddingLeft();
		int paddingRight = getPaddingRight();
		int height = getHeight();
		int lineHeight = getLineHeight();
		int spcingHeight = (int) getLineSpacingExtra();
		int count = (height - paddingTop - paddingBottom) / lineHeight;

		for (int i = 0; i < count; i++) {
			int baseline = lineHeight * (i + 1) + paddingTop - spcingHeight / 2;
			canvas.drawLine(left + paddingLeft, baseline, right - paddingRight,
					baseline, mPaint);
		}

		super.onDraw(canvas);
	}

}
