Background TransitionDrawable not redrawing on some devices
<p>I'm using a TransitionDrawable two go between two GradientDrawables, and I'm setting that as the background drawable of a Button. This works fine transitioning between two ColorDrawables, but when I try doing it with GradientDrawables I get some very strange results.</p>

<p>On my 2.3.5 device everything works peachy.
On my 4.2.2 device, the buttons just takes on the first gradient and don't redraw at all.</p>

<p>If I add a call to view.refreshDrawableState() or view.setBackgroundDrawable(drawable) after I've started the transition, it will refresh but things get even weirder:</p>

<ul>
<li>some buttons work correctly</li>
<li>some buttons flicker at points during the transition</li>
<li>one button, for whatever reason, transitions to black instead of to the second gradient drawable</li>
</ul>

<p>I am looping the transition with a recursive post to the view, but I don't think that's problem because I get the same problems when I don't do it.</p>

<p>Does anyone know what I can do to fix this? Here's the relevant code:</p>

<pre><code>private static void highlightView(View view, Context context) {

    TransitionDrawable drawable;

    GradientDrawable d1 = new GradientDrawable(Orientation.TOP_BOTTOM,                  new int[] { HIGHLIGHT_COLOR_1, HIGHLIGHT_COLOR_G1 });
    d1.setCornerRadius(3f);

        GradientDrawable d2 = new GradientDrawable(Orientation.TOP_BOTTOM, 
            new int[] { HIGHLIGHT_COLOR_2, HIGHLIGHT_COLOR_G2 });
    d2.setCornerRadius(3f);

    drawable = new TransitionDrawable(new Drawable[] { 
            d1,
            d2
    });
    view.setBackgroundDrawable(drawable);

    drawable.setCrossFadeEnabled(true);

    animateBackground(drawable, true, view);

}

private static void animateBackground(final TransitionDrawable drawable,
        final boolean forward, final View view) {
    if (view.getBackground() != drawable) return;

    if (forward) {
        drawable.startTransition(HIGHLIGHT_CYCLE / 2);
    } else {
        drawable.reverseTransition(HIGHLIGHT_CYCLE / 2);
    }

    view.postDelayed(new Runnable() {
        @Override
        public void run() {
            animateBackground(drawable, !forward, view);
        }
    }, HIGHLIGHT_CYCLE / 2);
    view.refreshDrawableState(); //without this, no transition occurs at all
}
</code></pre>
