http://developer.android.com/reference/android/graphics/drawable/GradientDrawable.html
要设置该特定参数(我假设您没有指定一个centerX值):
yourGradientDrawable.setGradientCenter(1.0f, 0.45f);
因此,以编程方式创建上述渐变(不同颜色除外):
GradientDrawable g = new GradientDrawable(Orientation.TL_BR, new int[] { getResources().getColor(R.color.startcolor), Color.rgb(255, 0, 0), Color.BLUE });g.setGradientType(GradientDrawable.RADIAL_GRADIENT);g.setGradientRadius(140.0f);g.setGradientCenter(0.0f, 0.45f);注意:对于径向渐变,方向将被忽略,但采用颜色的构造函数需要使用该方向。



