summaryrefslogtreecommitdiff
path: root/core/java/android/widget/StackView.java
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2010-12-02 21:48:53 -0800
committerDianne Hackborn <hackbod@google.com>2010-12-03 10:46:18 -0800
commit189ee18d6c6483ad63cc864267328259e2e00b95 (patch)
tree77ad8233f7fa19a13fcb2c2d0df80de42fac69a2 /core/java/android/widget/StackView.java
parent32820249adbcacb7a7a1d35f22a892badda03f3e (diff)
Implement smarter sizing of WRAP_CONTENT windows.
This extends the view hierarchy's measure pass to allow view to propagate up to their parent additional information besides just their measured size. They can now report that their measured width and/or height should be larger than the size their parent is limiting them to (even though by definition they need to contrain their reported measurements to the limits imposed by the parent). ViewRoot uses this information to determine if it should remeasure the window with a larger size limit to try to make it fit. Change-Id: I90af3b7a8ec45d0a5c003fb009857025209d83eb
Diffstat (limited to 'core/java/android/widget/StackView.java')
-rw-r--r--core/java/android/widget/StackView.java34
1 files changed, 25 insertions, 9 deletions
diff --git a/core/java/android/widget/StackView.java b/core/java/android/widget/StackView.java
index aee48c6633bf..64fb9858038f 100644
--- a/core/java/android/widget/StackView.java
+++ b/core/java/android/widget/StackView.java
@@ -281,7 +281,7 @@ public class StackView extends AdapterViewAnimator {
}
private void transformViewAtIndex(int index, View view) {
- float maxPerpectiveShift = mMeasuredHeight * PERSPECTIVE_SHIFT_FACTOR;
+ float maxPerpectiveShift = getMeasuredHeight() * PERSPECTIVE_SHIFT_FACTOR;
index = mMaxNumActiveViews - index - 1;
if (index == mMaxNumActiveViews - 1) index--;
@@ -297,7 +297,7 @@ public class StackView extends AdapterViewAnimator {
int stackDirection = (mStackMode == ITEMS_SLIDE_UP) ? 1 : -1;
float perspectiveTranslation = -stackDirection * r * maxPerpectiveShift;
float scaleShiftCorrection = stackDirection * (1 - scale) *
- (mMeasuredHeight * (1 - PERSPECTIVE_SHIFT_FACTOR) / 2.0f);
+ (getMeasuredHeight() * (1 - PERSPECTIVE_SHIFT_FACTOR) / 2.0f);
float transY = perspectiveTranslation + scaleShiftCorrection;
PropertyValuesHolder translationY = PropertyValuesHolder.ofFloat("translationY", transY);
@@ -897,8 +897,8 @@ public class StackView extends AdapterViewAnimator {
private void measureChildren() {
final int count = getChildCount();
- final int childWidth = mMeasuredWidth - mPaddingLeft - mPaddingRight;
- final int childHeight = Math.round(mMeasuredHeight*(1-PERSPECTIVE_SHIFT_FACTOR))
+ final int childWidth = getMeasuredWidth() - mPaddingLeft - mPaddingRight;
+ final int childHeight = Math.round(getMeasuredHeight()*(1-PERSPECTIVE_SHIFT_FACTOR))
- mPaddingTop - mPaddingBottom;
for (int i = 0; i < count; i++) {
@@ -925,17 +925,33 @@ public class StackView extends AdapterViewAnimator {
Math.round(mReferenceChildHeight * (1 + factor)) +
mPaddingTop + mPaddingBottom : 0;
} else if (heightSpecMode == MeasureSpec.AT_MOST) {
- heightSpecSize = haveChildRefSize ? Math.min(
- Math.round(mReferenceChildHeight * (1 + factor)) + mPaddingTop +
- mPaddingBottom, heightSpecSize) : 0;
+ if (haveChildRefSize) {
+ int height = Math.round(mReferenceChildHeight * (1 + factor))
+ + mPaddingTop + mPaddingBottom;
+ if (height <= heightSpecSize) {
+ heightSpecSize = height;
+ } else {
+ heightSpecSize |= MEASURED_STATE_TOO_SMALL;
+ }
+ } else {
+ heightSpecSize = 0;
+ }
}
if (widthSpecMode == MeasureSpec.UNSPECIFIED) {
widthSpecSize = haveChildRefSize ? mReferenceChildWidth + mPaddingLeft +
mPaddingRight : 0;
} else if (heightSpecMode == MeasureSpec.AT_MOST) {
- widthSpecSize = haveChildRefSize ? Math.min(mReferenceChildWidth + mPaddingLeft +
- mPaddingRight, widthSpecSize) : 0;
+ if (haveChildRefSize) {
+ int width = mReferenceChildWidth + mPaddingLeft + mPaddingRight;
+ if (width <= widthSpecSize) {
+ widthSpecSize = width;
+ } else {
+ widthSpecSize |= MEASURED_STATE_TOO_SMALL;
+ }
+ } else {
+ widthSpecSize = 0;
+ }
}
setMeasuredDimension(widthSpecSize, heightSpecSize);