@@ -107,6 +107,9 @@ public void setThumb(Drawable thumb) {
107107 }
108108 if (thumb != null ) {
109109 thumb .setCallback (this );
110+ if (canResolveLayoutDirection ()) {
111+ thumb .setLayoutDirection (getResolvedLayoutDirection ());
112+ }
110113
111114 // Assuming the thumb drawable is symmetric, set the thumb offset
112115 // such that the thumb will hang halfway off either edge of the
@@ -303,7 +306,16 @@ private void setThumbPos(int w, Drawable thumb, float scale, int gap) {
303306 // Canvas will be translated, so 0,0 is where we start drawing
304307 thumb .setBounds (thumbPos , topBound , thumbPos + thumbWidth , bottomBound );
305308 }
306-
309+
310+ @ Override
311+ public void onResolveDrawables (int layoutDirection ) {
312+ super .onResolveDrawables (layoutDirection );
313+
314+ if (mThumb != null ) {
315+ mThumb .setLayoutDirection (layoutDirection );
316+ }
317+ }
318+
307319 @ Override
308320 protected synchronized void onDraw (Canvas canvas ) {
309321 super .onDraw (canvas );
@@ -409,15 +421,25 @@ private void trackTouchEvent(MotionEvent event) {
409421 int x = (int )event .getX ();
410422 float scale ;
411423 float progress = 0 ;
412- if (x < mPaddingLeft ) {
413- scale = 0.0f ;
414- } else if (x > width - mPaddingRight ) {
415- scale = 1.0f ;
424+ if (isLayoutRtl ()) {
425+ if (x > width - mPaddingRight ) {
426+ scale = 0.0f ;
427+ } else if (x < mPaddingLeft ) {
428+ scale = 1.0f ;
429+ } else {
430+ scale = (float )(available - x + mPaddingLeft ) / (float )available ;
431+ progress = mTouchProgressOffset ;
432+ }
416433 } else {
417- scale = (float )(x - mPaddingLeft ) / (float )available ;
418- progress = mTouchProgressOffset ;
434+ if (x < mPaddingLeft ) {
435+ scale = 0.0f ;
436+ } else if (x > width - mPaddingRight ) {
437+ scale = 1.0f ;
438+ } else {
439+ scale = (float )(x - mPaddingLeft ) / (float )available ;
440+ progress = mTouchProgressOffset ;
441+ }
419442 }
420-
421443 final int max = getMax ();
422444 progress += scale * max ;
423445
0 commit comments