2011-05-31 13 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