Merge "Fix indeterminate ProgressBars with weird sizes and padding; optimize ActionBar measurement" into jb-mr1-dev

This commit is contained in:
Adam Powell
2012-08-08 16:04:35 -07:00
committed by Android (Google) Code Review
2 changed files with 10 additions and 7 deletions

View File

@@ -985,9 +985,13 @@ public class ProgressBar extends View {
}
private void updateDrawableBounds(int w, int h) {
// onDraw will translate the canvas so we draw starting at 0,0
int right = w - mPaddingRight - mPaddingLeft;
int bottom = h - mPaddingBottom - mPaddingTop;
// onDraw will translate the canvas so we draw starting at 0,0.
// Subtract out padding for the purposes of the calculations below.
w -= mPaddingRight + mPaddingLeft;
h -= mPaddingTop + mPaddingBottom;
int right = w;
int bottom = h;
int top = 0;
int left = 0;

View File

@@ -856,6 +856,7 @@ public class ActionBarView extends AbsActionBarView {
final int paddingRight = getPaddingRight();
final int height = maxHeight - verticalPadding;
final int childSpecHeight = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST);
final int exactHeightSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
int availableWidth = contentWidth - paddingLeft - paddingRight;
int leftOfCenter = availableWidth / 2;
@@ -871,16 +872,14 @@ public class ActionBarView extends AbsActionBarView {
} else {
homeWidthSpec = MeasureSpec.makeMeasureSpec(lp.width, MeasureSpec.EXACTLY);
}
homeLayout.measure(homeWidthSpec,
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
homeLayout.measure(homeWidthSpec, exactHeightSpec);
final int homeWidth = homeLayout.getMeasuredWidth() + homeLayout.getStartOffset();
availableWidth = Math.max(0, availableWidth - homeWidth);
leftOfCenter = Math.max(0, availableWidth - homeWidth);
}
if (mMenuView != null && mMenuView.getParent() == this) {
availableWidth = measureChildView(mMenuView, availableWidth,
childSpecHeight, 0);
availableWidth = measureChildView(mMenuView, availableWidth, exactHeightSpec, 0);
rightOfCenter = Math.max(0, rightOfCenter - mMenuView.getMeasuredWidth());
}