Reputation: 1722
why
TableRow.LayoutParams layout = new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1/11);
does not work but
String s = "0.0909";
float fVal = Float.valueOf(s).floatValue();
TableRow.LayoutParams layout = new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, fVal);
does?
I use this to make table rows fit in a table with dynamic table width.
Regards
Upvotes: 0
Views: 1383
Reputation: 328855
1/11
is an int (which happens to be 0), because both 1
and 11
are integers.
Try 1.0f / 11
instead to get a float value (or 1f / 11
but I find it less readable).
Upvotes: 2