5
这是我的颜色列表:如何以编程方式设置android:angle属性的GradientDrawable?
static ArrayList<Integer> colors;
static {
colors = new ArrayList<Integer>();
colors.add(Color.parseColor("#43CFCF"));
colors.add(Color.parseColor("#1C6E9B"));
colors.add(Color.parseColor("#AC88C0"));
colors.add(Color.parseColor("#EE5640"));
colors.add(Color.parseColor("#EFBF4D"));
}
这是我绘制数组:
static Drawable[] drawables;
static {
drawables = new Drawable[5];
drawables[0] = new GradientDrawable(Orientation.TL_BR, new int[]{colors.get(0), colors.get(1)});
drawables[1] = new GradientDrawable(Orientation.TL_BR, new int[]{colors.get(1), colors.get(2)});
drawables[2] = new GradientDrawable(Orientation.TL_BR, new int[]{colors.get(2), colors.get(3)});
drawables[3] = new GradientDrawable(Orientation.TL_BR, new int[]{colors.get(3), colors.get(4)});
drawables[4] = new GradientDrawable(Orientation.TL_BR, new int[]{colors.get(4), colors.get(0)});
}
现在,我遍历绘制[]和交叉淡入淡出的B/W第n和(n +1)可绘制,使用alpha动画。
现在,这是我的布局看起来像:
我的布局为长方形(GradientDrawable.Orientation:左上-BottomRight),但这种定位值未设置我的渐变线(颜色之间)从右上角绑定到矩形的左下角。如果我的布局是SquareShape,它会很好地工作。因此,我想以编程方式设置每个GradientDrawable的角度(不能使用xml,因为我在代码中创建了drawables,否则我将不得不为每个drawable创建5个xmls) 。
另外,如果我的方向是TL_BR,android:angle的值是如何工作的?角度是否随参考(轴)向TL_BR线(0弧度)而变化。
请帮忙!