• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps custom vertical seekbar is not working on API-23(Marshmallow)

GovindRai

Lurker
Jun 21, 2017
3
0
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.

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.
 
Can you please clarify the problem? "Not working" doesn't tell us much.
Thanks.

I have created custom Vertical graphics scroll bar in older version (API 22) and it properly displaying in all versions from API 10 to 22 and from API 24, 25 onwards its working properly. Its displaying graphics scroll bar ( example - Change the temperature slider indication )
But in Android Version 6.x(API Version 23) - Vertical graphics temperature slider scroll bar is not displaying and i dont have any clue why its not displaying specially in this build. For your information is custom build vertical scroll widget.

Please refer my code above.

The image showing slider is appearing from API-10 to API-25 Except API-23.where it just show blank screen.which i have attached.
 

Attachments

  • Screenshot_1498066557.png
    Screenshot_1498066557.png
    160.1 KB · Views: 1,232
  • f96dc986-d3ff-43e8-980d-7b37a116872c.jpg
    f96dc986-d3ff-43e8-980d-7b37a116872c.jpg
    16.7 KB · Views: 415
Last edited:
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones