Skip to content

Instantly share code, notes, and snippets.

@himalay
Forked from FokkeZB/README.md
Last active August 29, 2015 14:17
Show Gist options
  • Save himalay/b0c35232c308c4c9f095 to your computer and use it in GitHub Desktop.
Save himalay/b0c35232c308c4c9f095 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment