package com.example.test_project;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.widget.SeekBar;
public class CustomSeekBar extends SeekBar{
Paint paint;
int heigth;
int width;
int interval;
int Startpoint;
int StartingPoint;
int EndingPoint;
int Differnce;
private boolean StartUp;
public CustomSeekBar(Context context, AttributeSet attrs)
{
super(context, attrs);
paint=new Paint();
paint.setColor(Color.BLACK);
paint.setTextSize(30.0f);
StartUp=false;
}
public void IntializeValue(int startingPoint,int endingPoint,int difference)
{
this.StartingPoint=startingPoint;
this.EndingPoint=endingPoint;
this.Differnce=difference;
setProgress(2);
setMax(12);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
heigth=h;
width=w;
int parts=(EndingPoint/Differnce);
interval=width/parts;
System.out.println("111 width is "+width);
System.out.println("111 heigth is "+heigth);
System.out.println("111 interval is "+interval);
super.onSizeChanged(w, h, oldw, oldh);
}
@Override
protected synchronized void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
int diff=10;
System.out.println("ondraw 2");
int tempPoint=StartingPoint;
canvas.drawLine(Startpoint,15,width,15,paint);
canvas.drawLine(Startpoint,5,Startpoint,25,paint);
canvas.drawText(tempPoint+"", Startpoint,heigth, paint);
canvas.drawLine(Startpoint,5,Startpoint,25,paint);
Startpoint+=interval;
tempPoint+=Differnce;
canvas.drawText(tempPoint+"", Startpoint-diff,heigth, paint);
canvas.drawLine(Startpoint,5,Startpoint,25,paint);
Startpoint+=interval;
tempPoint+=Differnce;
canvas.drawText(tempPoint+"", Startpoint-diff,heigth, paint);
canvas.drawLine(Startpoint,5,Startpoint,25,paint);
Startpoint+=interval;
tempPoint+=Differnce;
canvas.drawText(tempPoint+"", Startpoint-diff,heigth, paint);
canvas.drawLine(Startpoint,5,Startpoint,25,paint);
Startpoint+=interval;
tempPoint+=Differnce;
canvas.drawText(tempPoint+"", Startpoint-diff,heigth, paint);
canvas.drawLine(Startpoint,5,Startpoint,25,paint);
Startpoint+=interval;
tempPoint+=Differnce;
canvas.drawText(tempPoint+"", Startpoint-diff,heigth, paint);
canvas.drawLine(Startpoint,5,Startpoint,25,paint);
Startpoint+=interval;
tempPoint+=Differnce;
diff=10;
canvas.drawText(tempPoint+"", Startpoint-diff,heigth, paint);
canvas.drawLine(Startpoint,5,Startpoint,25,paint);
Startpoint+=interval;
tempPoint+=Differnce;
canvas.drawText(tempPoint+"", Startpoint-diff,heigth, paint);
canvas.drawLine(Startpoint,5,Startpoint,25,paint);
Startpoint+=interval;
tempPoint+=Differnce;
canvas.drawText(tempPoint+"", Startpoint-diff,heigth, paint);
canvas.drawLine(Startpoint,5,Startpoint,25,paint);
Startpoint+=interval;
tempPoint+=Differnce;
canvas.drawText(tempPoint+"", Startpoint-diff,heigth, paint);
canvas.drawLine(Startpoint,5,Startpoint,25,paint);
Startpoint+=interval;
super.onDraw(canvas);
Startpoint=0;
System.out.println("ondraw");
}
}