2

I am creating GradientDrawable and it's working fine. But now I need to give centerX and centerY position of GradientDrawable and I am giving with below code

GradientDrawable gradientDrawable = new GradientDrawable();
gradientDrawable.setColors(new int[]{StartColor, EndColor});
gradientDrawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
gradientDrawable.setGradientCenter(CenterXPosition, CenterYPosition); // CenterYPosition = 0.5 and CenterXPosition = (0-100) values I am giving
viewGradientLayout.setBackground(gradientDrawable);

but It is not working. setGradientCenter is not changing anything in my drawable.

this is my Imageview in which I am showing my drawable.

enter image description here

Note:-

  1. I tried giving CenterXPosition values between 0.0 to 1
  2. I tried giving

    gradientDrawable.setShape(GradientDrawable.RECTANGLE);
    

gradient center stays at center position... without any movement.. What could be wrong? Thanks for your answers.

any other solution to show like it also accepted.

Bhaven Shah
  • 692
  • 1
  • 5
  • 18
  • I am have the exact problem, did you ever find a solution to this? – AndroidDev123 Feb 02 '21 at 17:34
  • 2
    @AndroidDev123 Sorry to say but the answer is No. And It is a google developer's issue and it is a registered issue already. link :- https://issuetracker.google.com/issues/36944181 – Bhaven Shah May 08 '21 at 07:19

0 Answers0