1. Are you ready for the Galaxy S20? Here is everything we know so far!

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

Discussion in 'Android Development' started by GovindRai, Jun 21, 2017.

  1. GovindRai

    GovindRai Lurker
    Thread Starter

    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 (Text):
    1.  
    2. <com.jci.thermostat.uc.common.VerticalSeekBar
    3.        android:layout_width="32dp"
    4.        android:layout_height="match_parent"
    5.        android:id="@+id/setpointBar"
    6.        android:splitTrack="false"
    7.        android:thumb="@drawable/thumb_vertical"
    8.        android:progressDrawable="@android:color/transparent"
    9.        android:background="@android:color/transparent"
    10.        android:thumbOffset="11dp"
    11.        android:paddingLeft="11dp"
    12.        android:paddingRight="11dp" />
    13.  
    Code (Text):
    1.  
    2. public class VerticalSeekBar extends SeekBar {
    3.  
    4. public VerticalSeekBar(Context context, AttributeSet attrs) {
    5.    super(context, attrs);
    6. }
    7.  
    8. [USER=1021285]@override[/USER]
    9. public void onDraw(Canvas canvas) {
    10.    canvas.rotate(-90);
    11.    canvas.translate(-getHeight(),0);
    12.    super.onDraw(canvas);
    13. }
    14.  
    15.  
    16. [USER=1021285]@override[/USER]
    17. protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    18.    super.onMeasure(heightMeasureSpec, widthMeasureSpec);
    19.    setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth());
    20. }
    21.  
    22. protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    23.    super.onSizeChanged(h, w, oldh, oldw);
    24. }
    25.  
    26. [USER=1021285]@override[/USER]
    27. public boolean onTouchEvent(MotionEvent event) {
    28.    if (!isEnabled()) {
    29.        return isClickable() || isLongClickable();
    30.    }
    31.  
    32.    switch (event.getAction()) {
    33.        case MotionEvent.ACTION_DOWN:
    34.        case MotionEvent.ACTION_UP:
    35.            setPressed(MotionEvent.ACTION_UP != event.getAction());
    36.        case MotionEvent.ACTION_MOVE:
    37.            final int paddingLeft = getPaddingLeft();
    38.            final int height = getHeight();
    39.            final int available = height - paddingLeft - getPaddingRight();
    40.            final int max = getMax();
    41.            int progress = (int)((height - event.getY() - paddingLeft) * max / available);
    42.            progress = Math.min(max, Math.max(0, progress));
    43.            setProgress(progress);
    44.            break;
    45.        case MotionEvent.ACTION_CANCEL:
    46.        case MotionEvent.ACTION_OUTSIDE:
    47.            setPressed(false);
    48.            break;
    49.    }
    50.    return true;
    51. }
    52.  
    53. [USER=1021285]@override[/USER]
    54. public synchronized void setProgress(int progress) {
    55.    if (progress != getProgress()) {
    56.        super.setProgress(progress);
    57.        onSizeChanged(getWidth(), getHeight(), 0, 0);
    58.    }
    59. }
    60. }
    61.  
    if you need more information plz let me know.
     



    1. Download the Forums for Android™ app!


      Download

       
  2. Deleted User

    Deleted User Guest

    Can you please clarify the problem? "Not working" doesn't tell us much.
    Thanks.
     
  3. Phalon4

    Phalon4 Android Enthusiast

    Go into Settings look for Apps then in upper right corner tick 3 dots and tick Reset App permissions and see will that help. This options varies from device from device.
     
  4. GovindRai

    GovindRai Lurker
    Thread Starter

    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.
     

    Attached Files:

    #4 GovindRai, Jun 21, 2017
    Last edited: Jun 21, 2017
  5. GovindRai

    GovindRai Lurker
    Thread Starter

    Sorry, its not working when reset app preference functionalities.
     
Loading...
Similar Threads - custom vertical seekbar
  1. Ben Foster
    Replies:
    1
    Views:
    157
  2. Sky Weatherman
    Replies:
    2
    Views:
    330
  3. RianRusdani
    Replies:
    3
    Views:
    285
  4. 14km
    Replies:
    2
    Views:
    336
  5. Raza Shaikh
    Replies:
    1
    Views:
    485
  6. Khalil Ferhat
    Replies:
    4
    Views:
    600
  7. JamzApplications
    Replies:
    1
    Views:
    326
  8. frozen_sun
    Replies:
    3
    Views:
    425
  9. Hajji Abdoullah
    Replies:
    3
    Views:
    1,798
  10. Shosh
    Replies:
    1
    Views:
    843

Share This Page

Loading...