/** * Sets the size of the view. This should cause layout of the view along the given axis, if it has * any layout duties. * * @param width the width >= 0 * @param height the height >= 0 */ public void setSize(float width, float height) { updateMetrics(); if ((int) width != getWidth()) { // invalidate the view itself since the childrens // desired widths will be based upon this views width. preferenceChanged(null, true, true); widthChanging = true; } super.setSize(width, height); widthChanging = false; }
/** * Lays out the children. If the span along the flow axis has changed, layout is marked as invalid * which which will cause the superclass behavior to recalculate the layout along the box axis. * The FlowStrategy.layout method will be called to rebuild the flow rows as appropriate. If the * height of this view changes (determined by the perferred size along the box axis), a * preferenceChanged is called. Following all of that, the normal box layout of the superclass is * performed. * * @param width the width to lay out against >= 0. This is the width inside of the inset area. * @param height the height to lay out against >= 0 This is the height inside of the inset area. */ protected void layout(int width, int height) { final int faxis = getFlowAxis(); int newSpan; if (faxis == X_AXIS) { newSpan = (int) width; } else { newSpan = (int) height; } if (layoutSpan != newSpan) { layoutChanged(faxis); layoutChanged(getAxis()); layoutSpan = newSpan; } // repair the flow if necessary if (!isLayoutValid(faxis)) { final int heightAxis = getAxis(); int oldFlowHeight = (int) ((heightAxis == X_AXIS) ? getWidth() : getHeight()); strategy.layout(this); int newFlowHeight = (int) getPreferredSpan(heightAxis); if (oldFlowHeight != newFlowHeight) { View p = getParent(); if (p != null) { p.preferenceChanged(this, (heightAxis == X_AXIS), (heightAxis == Y_AXIS)); } // PENDING(shannonh) // Temporary fix for 4250847 // Can be removed when TraversalContext is added Component host = getContainer(); if (host != null) { // nb idk 12/12/2001 host should not be equal to null. We need to add assertion here host.repaint(); } } } super.layout(width, height); }