Saturday, June 30, 2012

Specify your widget margin/padding property values in “dip” units

This one baffled me for a while.  I had an Android layout open in the Eclipse graphical layout editor with a TextView component.  Every time I changed any of the Margin or Padding properties the widgets disappeared off the layout, even if I entered the smallest non-zero value of 1.  Turns out that I needed to add the string “dip” after the number.  I guess the default units for margin is something that translates to a huge distance on the layout.  For example, instead of 4 enter 4dip.

No comments:

Post a Comment