Pages

Removing hard coded dimensions


You can specify a XML file in the res\values folder called dimensions.xml (the name is abitrary)
 
<?xml version="1.0" encoding="utf-8"?>

<

resources>

<dimen name="numkey_width">60px</dimen>

<dimen name="numkey_height">40px</dimen>

<dimen name="numkey_margin">1px</dimen>

</

resources>
 
You can then refer to the dimensions in the layout XML like this:
 
android:layout_width="@dimen/numkey_width"
android:layout_height="@dimen/numkey_height"
android:layout_marginTop="@dimen/numkey_margin"
android:layout_marginLeft="@dimen/numkey_margin"