Based on CQM's answer and on ovokerie-ogbeta's answer to another question I've come up with this solution:
if (colorAsString.length() == 4) { // #XXX
colorAsString = colorAsString.replaceAll("#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])", "#$1$1$2$2$3$3");
}
int color = Color.parseColor(colorAsString);