GovindRai
Lurker
I have created a custom vertical seekbar (graphics) which is working on API-10 to API-22 and API -24. But its not working in API-23 (Marshmallow 6.x). Could you please help me why its breaking the widget / seekbar function.
if you need more information plz let me know.
Code:
<com.jci.thermostat.uc.common.VerticalSeekBar
android:layout_width="32dp"
android:layout_height="match_parent"
android:id="@+id/setpointBar"
android:splitTrack="false"
android:thumb="@drawable/thumb_vertical"
android:progressDrawable="@android:color/transparent"
android:background="@android:color/transparent"
android:thumbOffset="11dp"
android:paddingLeft="11dp"
android:paddingRight="11dp" />
Code:
public class VerticalSeekBar extends SeekBar {
public VerticalSeekBar(Context context, AttributeSet attrs) {
super(context, attrs);
}
[USER=1021285]@override[/USER]
public void onDraw(Canvas canvas) {
canvas.rotate(-90);
canvas.translate(-getHeight(),0);
super.onDraw(canvas);
}
[USER=1021285]@override[/USER]
protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(heightMeasureSpec, widthMeasureSpec);
setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth());
}
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(h, w, oldh, oldw);
}
[USER=1021285]@override[/USER]
public boolean onTouchEvent(MotionEvent event) {
if (!isEnabled()) {
return isClickable() || isLongClickable();
}
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_UP:
setPressed(MotionEvent.ACTION_UP != event.getAction());
case MotionEvent.ACTION_MOVE:
final int paddingLeft = getPaddingLeft();
final int height = getHeight();
final int available = height - paddingLeft - getPaddingRight();
final int max = getMax();
int progress = (int)((height - event.getY() - paddingLeft) * max / available);
progress = Math.min(max, Math.max(0, progress));
setProgress(progress);
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_OUTSIDE:
setPressed(false);
break;
}
return true;
}
[USER=1021285]@override[/USER]
public synchronized void setProgress(int progress) {
if (progress != getProgress()) {
super.setProgress(progress);
onSizeChanged(getWidth(), getHeight(), 0, 0);
}
}
}
if you need more information plz let me know.