0

For a view in android, I need to set margin in float value.

I'm using this, but I'm able to set margin in int only.

lp.setMargins(50, 35, 0, 0);
        starImage.setLayoutParams(lp);

How to pass float values for margin of a view ?

Ronn
  • 183
  • 2
  • 13
  • 1
    setMargins supports only pixel mentioned as integer only. If your intention is to convert from one unit to other, you can refer these posts: http://stackoverflow.com/questions/2406449/does-setwidthint-pixels-use-dip-or-px – Ganesh Kumar Aug 12 '15 at 05:22
  • ok. I too read the documentation but I was thinking if there is any hack to pass float values. One method I figured out is to round up the float to next integer. – Ronn Aug 12 '15 at 06:20

0 Answers0