I have SeekBars in an application which operate as expected and return values that I expect. However, on Android 2.x they display oddly.

I’ve looked for other similar things such as Android Drawable setLevel(); not filling SeekBar appropriately, but that is for a custom drawable. Otherwise I’m having trouble coming up with search terms for this issue to get anywhere.
In this case, all I’m doing is
SeekBar seekBar = (SeekBar)dialogLayout.findViewById(R.id.my_seek);
seekBar.setProgress(5);
seekBar.setMax(20);
If I move the slider, it properly fills the SeekBar the moment it’s moved.
Any idea on what is going on?
After posting this, I realized the problem was the order of the method calls.
Incorrect
Correct
From what I gather if you first call setProgress(5) in my case, the system will set the drawable to display the progress as 5% since it is 5 / 100 and 100 is the default maximum.
Then if you call setMax(20), the value of 5 is still valid but the drawable is no longer valid and is not recalculated to display as 25% (5 / 20) of the bar.
Doing setMax(20) first will compel the drawable to be calculated correctly once you use setProgress(5).
In case it’s of use to anyone, I tested this on Android 2.1, 2.2, 4.1 and 4.2.
Essentially to remain backwards compatible, always do setMax(int) first and then setProgress(int).