Convert RGB to HEX programatically - Android

前端 未结 1 1001
情书的邮戳
情书的邮戳 2020-12-22 03:49

So Im making an app that converts RGB Colors to Hexadecimal (ex. #FFFFFF). I have three edittext for Red, Green and Blu. When I input values for every edittext like (255,255

1条回答
  •  囚心锁ツ
    2020-12-22 04:49

    Just pass an array of 3 colors red, green, blue to this function

      int[] color={200,170,100};
      btn.setBackgroundColor(getHexColor(color));
    
    
      public static int getHexColor(int[] color) {
        return android.graphics.Color.rgb(color[0], color[1], color[2]);
     }
    

    0 讨论(0)
提交回复
热议问题