Convert color in int to color for HTML - Android android.graphics

Android examples for android.graphics:Color

Description

Convert color in int to color for HTML

Demo Code

public class Main {

  public static String colorHTML(int color) {
    String hex = Integer.toHexString(color & 0xffffff);
    while (hex.length() < 6) {
      hex = '0' + hex;
    }/*from  w  ww  .  j  ava 2s  . c o  m*/
    return '#' + hex;
  }

}

Related Tutorials