I want to make a custom view for my android app which has a functionality to change its background colour "gradient".
Something like this, but the centre handle can be moved left and right using code
The catch is that I want a function something like in the view:
changeBackgroundGradient(ratio, startColour, centreColour, endColour);
ratio (having value between 0 to 1) which is given by formula leftValue/rightValue determining the shape of the gradient
startColour, centreColour and endColour being the colours of which the gradient consists of
How would i make this function?
Regards

You can try below code as this is working for me to change my toolbar color dynamically
Update
Check this for more options to apply gradient color in view.