Java tutorial
//package com.java2s; //License from project: Apache License import android.graphics.Color; import java.util.regex.Pattern; public class Main { public static int HextoColor(String color) { // #00000000 - #ffffffff String reg = "#[a-f0-9A-F]{8}"; if (!Pattern.matches(reg, color)) { color = "#ffffffff"; } return Color.parseColor(color); } }