【问题标题】:Android: draw arc with gradient from topAndroid:从顶部绘制带有渐变的弧
【发布时间】:2016-03-08 12:14:32
【问题描述】:

渐变从 3 点开始 - 但我希望它从 12 点开始。

 int color1 = Color.RED;
 int color2 = Color.BLUE;
 int[] colors = {color1, color2};
 Shader gradient = new SweepGradient(width / 2, height / 2, colors, null);
 mArcPaint.setShader(gradient);

关于如何将开始旋转到 12 的任何建议?我试过了

 Matrix matrix = new Matrix();
 matrix.postRotate(270f);
 gradient.setLocalMatrix(matrix);

但它对我不起作用。

【问题讨论】:

    标签: android automatic-ref-counting paint gradient


    【解决方案1】:

    需要指定Rotate pointX, pointY
    在您的情况下:

    Matrix matrix = new Matrix();
    matrix.postRotate(270f,width / 2, height / 2);
    gradient.setLocalMatrix(matrix);
    

    我使用着色器绘制圆在下面显示不同的情况

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-20
      • 1970-01-01
      • 1970-01-01
      • 2012-01-02
      • 1970-01-01
      • 1970-01-01
      • 2013-01-03
      • 1970-01-01
      相关资源
      最近更新 更多