I'm trying to change the progress color of a custom vertical SeekBar How can I get a working vertical SeekBar in Android? and it works fine if I put this code in a View.OnTouchListener:
VerticalSeekBar verticalSeekBar1 = (VerticalSeekBar)verticalSeekBar;
Rect bounds = verticalSeekBar1.getProgressDrawable().getBounds();
int progr = verticalSeekBar1.getProgress();
int max = verticalSeekBar1.getMax();
int width = verticalSeekBar1.getWidth();
int height = verticalSeekBar1.getHeight();
prDr = verticalSeekBar1.getProgressDrawable();
verticalSeekBar1.setProgressDrawable(r.getDrawable(R.drawable.myprogress));
verticalSeekBar1.getProgressDrawable().setBounds(bounds);
verticalSeekBar1.setMax(max);
verticalSeekBar1.setProgress(1);
verticalSeekBar1.setProgress(progr);
verticalSeekBar1.onSizeChanged(width, height);
verticalSeekBar1.refreshDrawableState();
However, if I put this same code in another thread it works partially since the thumb of the seekbar does not go to the right position and instead goes down but the color of the progress works well and gets to the last position. I figured that the method onSizeChanged is probably causing this. I debugged it and found out that in both scenarios the onSizeChanged method has the appropriate arguments but in the code from the thread it does not update the seekbar.
I already tried moving this code to UI's thread but does not work either.