我正在尝试为动态壁纸创建渐变背景。我可以用两种颜色创建它,但它不允许我有三种颜色。
以下是我目前使用的代码:
int[] colors = { Color.GREEN, Color.MAGENTA, Color.YELLOW };
float[] positions = {0, 1, 2};
LinearGradient gradient = new LinearGradient(0, 0, 0, height, colors,
positions, android.graphics.Shader.TileMode.CLAMP);
结果是从绿色到洋红色的渐变,但没有任何黄色。任何帮助将不胜感激。这是我目前得到的结果的图像: