2011-05-31 10 views
4
ShapeDrawable.ShaderFactory sf = new ShapeDrawable.ShaderFactory() { 
     @Override 
     public Shader resize(int width, int height) { 
      LinearGradient lg = new LinearGradient(0, 0, 0, border.getHeight(), 
       new int[] { 
        Color.CYAN, 
        Color.WHITE, 
        Color.WHITE 
        }, //substitute the correct colors for these 
       new float[] { 
        0, 0.45f, 0.55f, 1 }, 
       Shader.TileMode.REPEAT); 
      return lg; 
     } 
    } 

中的LinearGradient颜色在这个代码,而不是使用Color.CYAN我想插入该颜色的十六进制值。有什么建议么?如何使用十六进制值来指定的Android

回答

4
new int[] { 
    Color.parseColor("#00FFFF"), 
    Color.WHITE, 
    Color.WHITE 
}, 
+0

它说构造函数(int,int,int)没有定义。我如何定义它? – Khush 2011-05-31 05:57:22

+0

更好,只有1 int? – oliholz 2011-05-31 05:58:36

+0

我不知道。需要它的渐变效果..我如何定义1 int ?? – Khush 2011-05-31 05:59:58