2

How it is possible to get Gradientrawable colors set by setColors(@ColorInt int[] colors) ?

Any help will be appricated.

TooCool
  • 10,598
  • 15
  • 60
  • 85

1 Answers1

0

Please reference GradientDrawable.java then make some proper modification for result as required.

    public class ColorGradientDrawable extends Drawable {
        ...
        private int mColor; // this is the color which you try to get
        ...
        // original setColor function with little modification
        public void setColor(int argb) {
            mColor = argb;
            mGradientState.setSolidColor(argb);
            mFillPaint.setColor(argb);
            invalidateSelf();
        }

// that's how I get the color from this drawable class

        public int getColor() {
            return mColor;
        }
        ...

// This is same as GradientState, just make some proper modification to make it compilable

        final public static class GradientState extends ConstantState {
            ...
        }
    }
Androider
  • 3,833
  • 2
  • 14
  • 24