I want to have the functionality of a SeekBar, but customize the line (it's vertical) to be a rectangle with the colors filled per segment of the max I set the bar to. Here is my class which I extend the SeekBar:
public class VerticalSeekBar extends SeekBar {
private static final int NUMBER_OF_MINUTES = 120;
private Paint mPaint = new Paint();
public VerticalSeekBar(Context context, AttributeSet attrs) {
super(context, attrs);
setMax(NUMBER_OF_MINUTES - 1);
}
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(h, w, oldh, oldw);
}
@Override
protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(heightMeasureSpec, widthMeasureSpec);
setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth());
}
protected void onDraw(Canvas canvas) {
canvas.rotate(90);
canvas.translate(0, -getWidth());
super.onDraw(canvas);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (!isEnabled()) {
return false;
}
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_MOVE:
case MotionEvent.ACTION_UP:
int i=0;
i=getMax() - (int) (getMax() * event.getY() / getHeight());
setProgress(getMax()-i);
onSizeChanged(getWidth(), getHeight(), 0, 0);
break;
case MotionEvent.ACTION_CANCEL:
break;
}
return true;
}
}
I want to have a thick vertical line (rectangle) which I can fill the color for each segment of the 120 max I set. Here is an image:
I currently just have a basic vertical seekBar with a thumb as the slider and it corresponds to the position in a listview. I need the seekBar for it pairs with a listView and dependent on where the slider is, I show that portion of the listview.