Android - How to draw an arc based gradient

后端 未结 3 1541
梦毁少年i
梦毁少年i 2020-12-04 19:54

I am trying to create an arc (variable number of degrees) that gradually goes from one color to another. From example from blue to red:

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-04 20:22

    To add to Yoav's solution.

    On my Galaxy Nexus 4.2 stock Android, the solution given doesn't work.

    If the array doesn't contain a 0.0f and 1.0f, it appears to be ignored.

    My final solution was:

    int[] colors = {Color.RED, Color.BLUE, Color.RED}; 
    float[] positions = {0, Xf/360f, 1};
    

提交回复
热议问题