float (int axis) { float baseSpan = super.getPreferredSpan(axis); if (axis == View.X_AXIS) { return baseSpan; } else { int availableWidth = getAvailableWidth(); if (availableWidth <= 0) return baseSpan; float baseXSpan = super.getPreferredSpan(View.X_AXIS); if (baseXSpan <= 0) return baseSpan; if (availableWidth > baseXSpan) { availableWidth = (int)baseXSpan; } if (myAvailableWidth > 0 && availableWidth != myAvailableWidth) { preferenceChanged(null, false, true); } myAvailableWidth = availableWidth; return baseSpan * availableWidth / baseXSpan; } }