-
Notifications
You must be signed in to change notification settings - Fork 11
Width & height expressions
a-student edited this page May 27, 2019
·
2 revisions
The width and height expressions define vector drawable dimensions based on SVG properties.
| Expression member | Type | Description |
|---|---|---|
| w | Double |
SVG image width in pixels. Fallbacks to the SVG viewport width if unset |
| h | Double |
SVG image height in pixels. Fallbacks to the SVG viewport height if unset |
| vw | Double |
SVG viewport width |
| vh | Double |
SVG viewport height |
| f(x) |
x – Double, returns String
|
Properly formats the number x into a string |
| + | String |
String concatenation |
| +, -, *, / | Double |
Arithmetic operations |
| Math.min(x, y) | Double |
Returns the minimum value of x and y |
| Math.max(x, y) | Double |
Returns the maximum value of x and y |
| Width and height expressions | Result |
|---|---|
Width: f(w / 2) + "dp", height: f(h / 2) + "dp"
|
Vector drawable is half the size of the original SVG image |
Width: f(vw) + "dp", height: f(vh) + "dp"
|
Explicitly specified SVG size is ignored |
Width: "12.3dp", height: "45.6dp"
|
Vector drawable of fixed size |