Skip to content

Instantly share code, notes, and snippets.

@FokkeZB
Created April 19, 2013 08:59
Show Gist options
  • Save FokkeZB/5419074 to your computer and use it in GitHub Desktop.
Save FokkeZB/5419074 to your computer and use it in GitHub Desktop.
Setting default unit of measurement.

To make sure your lay-outs look pretty much the same on all devices, including the thousands of different Android resolutions and densities, it's always best to use the 'dp' unit. However, typing '10dp' instead of 10 is quite a pain. A pain you can easily take away by changing the default unit in your tiapp.xml.

var view = Ti.UI.createView({
width: 100,
height: '100dp' // Is now exactly the same as the previous line
});
<property name="ti.ui.defaultunit" type="string">dp</property>
@nuno
Copy link

nuno commented Apr 19, 2013

Excellent tip!

@iantearle
Copy link

Would be great if there was something like this for setting the font family too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment