3

I have trying to change background color when user select different options.

For that I am creating TransitionDrawable at runtime. Its works fine. But my Problem is when I change my view background using setDrawableBackground(), Half of my screen views are override by the shape drawable.

Here is My TransitionDrawable code,

public static TransitionDrawable getTransitionDrawable (ShapeDrawable start, ShapeDrawable end){
    ShapeDrawable[] mDrawableSet = {start,end};
    TransitionDrawable tDrawable = new TransitionDrawable(mDrawableSet);
    return tDrawable;
}

This is my ShapeDrawble creation code

    public static ShapeDrawable getShapeDrawable (int[] colors){
      ShapeDrawable mDrawable = new ShapeDrawable(new RectShape());
      SweepGradient sg = new SweepGradient(0, 1,colors , null);
      mDrawable.getPaint().setShader( new SweepGradient(0, 0,colors , null));
      return mDrawable;
}

I have write below code to apply the color transition

holder.setBackgroundDrawable(AnimUtils.DEFAULT_TO_SUCCESS_TRANSITION);
                    transition = (TransitionDrawable) holder
                            .getBackground();
                    transition.startTransition(2000);

Help me to fix my issue...

Thanks in Advance.

Prakash M
  • 651
  • 3
  • 13

0 Answers0