---
# System prepended metadata

title: Color hex <-> dec
tags: [實作相關]

---

Color hex <-> dec
===

* Color from int
```java=
int myColor = 0xFF3F51B5;
myView.setBackgroundColor(myColor);
```

* Color from String
```java=
int myColor = Color.parseColor("#3F51B5");
myView.setBackgroundColor(myColor);
```

## Ref.
[How to get a Color from hexadecimal Color String](https://stackoverflow.com/questions/5248583/how-to-get-a-color-from-hexadecimal-color-string)

###### tags: `實作相關`