I want to animate the center of a linear gradient, so that at the beginning the whole drawable is color1 and at the end the whole drawable is color2 and in between the center of the gradient moves from left to right.
GradientDrawable gd = new GradientDrawable(
GradientDrawable.Orientation.LEFT_RIGHT,
new int[] {color1, color2});
gd.setCornerRadius(0f);
gd.setGradientCenter(x, 0);
view.setBackgroundDrawable(gd);
The problem is that setGradientCenter doesn't make any difference. According to this answer https://stackoverflow.com/a/14383974/1395697 there is an issue with setGradientCenter() but the solution in this answer doesn't work for me because I change the gradient in onTouch() when the user swipes his finger over the view, so it needs to be really fast.
Is there a way to do this?
I want to do something like this (all the touch stuff works great but not the animated gradient):