@@ -867,16 +867,18 @@ private void measureChildrenWithMargins(int widthSpec, int heightSpec, boolean f
867867 if (firstPass ) {
868868 measureChildWithMargins2 (c , widthSpec , heightSpec , lp .width , lp .height );
869869 } else {
870- Spec spec = (orientation == HORIZONTAL ) ? lp .columnSpec : lp .rowSpec ;
870+ boolean horizontal = (orientation == HORIZONTAL );
871+ Spec spec = horizontal ? lp .columnSpec : lp .rowSpec ;
871872 if (spec .alignment == FILL ) {
872873 Interval span = spec .span ;
873- Axis axis = ( orientation == HORIZONTAL ) ? horizontalAxis : verticalAxis ;
874+ Axis axis = horizontal ? horizontalAxis : verticalAxis ;
874875 int [] locations = axis .getLocations ();
875- int size = locations [span .max ] - locations [span .min ];
876- if (orientation == HORIZONTAL ) {
877- measureChildWithMargins2 (c , widthSpec , heightSpec , size , lp .height );
876+ int cellSize = locations [span .max ] - locations [span .min ];
877+ int viewSize = cellSize - getTotalMargin (c , horizontal );
878+ if (horizontal ) {
879+ measureChildWithMargins2 (c , widthSpec , heightSpec , viewSize , lp .height );
878880 } else {
879- measureChildWithMargins2 (c , widthSpec , heightSpec , lp .width , size );
881+ measureChildWithMargins2 (c , widthSpec , heightSpec , lp .width , viewSize );
880882 }
881883 }
882884 }
0 commit comments