Convert RGB to HEX programatically - Android

前端 未结 1 1003
情书的邮戳
情书的邮戳 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)
提交回复
热议问题