sumPref = spans[i];
sumPref += spans[i];
  protected void layoutMajorAxis(int targetSpan, int axis, int[] offsets,                                 int[] spans)  {    // Set the spans to the preferred sizes. Determine the space    // that we have to adjust the sizes afterwards.    long sumPref = 0;    int n = getViewCount();    for (int i = 0; i < n; i++)      {        View child = getView(i);        spans[i] = (int) child.getPreferredSpan(axis);        sumPref = spans[i];      }    // Try to adjust the spans so that we fill the targetSpan.    long diff = targetSpan - sumPref;    float factor = 0.0F;    int[] diffs = null;    if (diff != 0)      {        long total = 0;        diffs = new int[n];        for (int i = 0; i < n; i++)          {            View child = getView(i);            int span;            if (diff < 0)              {                span = (int) child.getMinimumSpan(axis);                diffs[i] = spans[i] - span;              }            else              {                span = (int) child.getMaximumSpan(axis);                diffs[i] = span - spans[i];              }            total += span;          }        float maxAdjust = Math.abs(total - sumPref);        factor = diff / maxAdjust;        factor = Math.min(factor, 1.0F);        factor = Math.max(factor, -1.0F);      }    // Actually perform adjustments.    int totalOffs = 0;    for (int i = 0; i < n; i++)      {        offsets[i] = totalOffs;        if (diff != 0)          {            float adjust = factor * diffs[i];            spans[i] += Math.round(adjust);          }        // Avoid overflow here.        totalOffs = (int) Math.min((long) totalOffs + (long) spans[i],                                    Integer.MAX_VALUE);      }  }