Loading core/java/android/widget/RelativeLayout.java +23 −21 Original line number Diff line number Diff line Loading @@ -394,6 +394,8 @@ public class RelativeLayout extends ViewGroup { } } // TODO: we need to find another way to implement RelativeLayout // This implementation cannot handle every case @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (mDirtyHierarchy) { Loading Loading @@ -683,28 +685,16 @@ public class RelativeLayout extends ViewGroup { * @param myHeight Height of the RelativeLayout */ private void measureChild(View child, LayoutParams params, int myWidth, int myHeight) { int childHeightMeasureSpec = getChildMeasureSpec(params.mTop, params.mBottom, params.height, params.topMargin, params.bottomMargin, mPaddingTop, mPaddingBottom, myHeight); switch (MeasureSpec.getMode(childHeightMeasureSpec)) { case MeasureSpec.AT_MOST: if (child.getMeasuredHeight() <= MeasureSpec.getSize(childHeightMeasureSpec)) { return; } break; case MeasureSpec.EXACTLY: if (child.getMeasuredHeight() == MeasureSpec.getSize(childHeightMeasureSpec)) { return; } break; } int childWidthMeasureSpec = getChildMeasureSpec(params.mLeft, params.mRight, params.width, params.leftMargin, params.rightMargin, mPaddingLeft, mPaddingRight, myWidth); int childHeightMeasureSpec = getChildMeasureSpec(params.mTop, params.mBottom, params.height, params.topMargin, params.bottomMargin, mPaddingTop, mPaddingBottom, myHeight); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); } Loading Loading @@ -910,6 +900,8 @@ public class RelativeLayout extends ViewGroup { } else if (childParams.alignWithParent && rules[LEFT_OF] != 0) { if (myWidth >= 0) { childParams.mRight = myWidth - mPaddingRight - childParams.rightMargin; } else { // FIXME uh oh... } } Loading @@ -934,16 +926,20 @@ public class RelativeLayout extends ViewGroup { } else if (childParams.alignWithParent && rules[ALIGN_RIGHT] != 0) { if (myWidth >= 0) { childParams.mRight = myWidth - mPaddingRight - childParams.rightMargin; } else { // FIXME uh oh... } } if (rules[ALIGN_PARENT_LEFT] != 0) { if (0 != rules[ALIGN_PARENT_LEFT]) { childParams.mLeft = mPaddingLeft + childParams.leftMargin; } if (rules[ALIGN_PARENT_RIGHT] != 0) { if (0 != rules[ALIGN_PARENT_RIGHT]) { if (myWidth >= 0) { childParams.mRight = myWidth - mPaddingRight - childParams.rightMargin; } else { // FIXME uh oh... } } } Loading @@ -962,6 +958,8 @@ public class RelativeLayout extends ViewGroup { } else if (childParams.alignWithParent && rules[ABOVE] != 0) { if (myHeight >= 0) { childParams.mBottom = myHeight - mPaddingBottom - childParams.bottomMargin; } else { // FIXME uh oh... } } Loading @@ -986,16 +984,20 @@ public class RelativeLayout extends ViewGroup { } else if (childParams.alignWithParent && rules[ALIGN_BOTTOM] != 0) { if (myHeight >= 0) { childParams.mBottom = myHeight - mPaddingBottom - childParams.bottomMargin; } else { // FIXME uh oh... } } if (rules[ALIGN_PARENT_TOP] != 0) { if (0 != rules[ALIGN_PARENT_TOP]) { childParams.mTop = mPaddingTop + childParams.topMargin; } if (rules[ALIGN_PARENT_BOTTOM] != 0) { if (0 != rules[ALIGN_PARENT_BOTTOM]) { if (myHeight >= 0) { childParams.mBottom = myHeight - mPaddingBottom - childParams.bottomMargin; } else { // FIXME uh oh... } } Loading Loading
core/java/android/widget/RelativeLayout.java +23 −21 Original line number Diff line number Diff line Loading @@ -394,6 +394,8 @@ public class RelativeLayout extends ViewGroup { } } // TODO: we need to find another way to implement RelativeLayout // This implementation cannot handle every case @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (mDirtyHierarchy) { Loading Loading @@ -683,28 +685,16 @@ public class RelativeLayout extends ViewGroup { * @param myHeight Height of the RelativeLayout */ private void measureChild(View child, LayoutParams params, int myWidth, int myHeight) { int childHeightMeasureSpec = getChildMeasureSpec(params.mTop, params.mBottom, params.height, params.topMargin, params.bottomMargin, mPaddingTop, mPaddingBottom, myHeight); switch (MeasureSpec.getMode(childHeightMeasureSpec)) { case MeasureSpec.AT_MOST: if (child.getMeasuredHeight() <= MeasureSpec.getSize(childHeightMeasureSpec)) { return; } break; case MeasureSpec.EXACTLY: if (child.getMeasuredHeight() == MeasureSpec.getSize(childHeightMeasureSpec)) { return; } break; } int childWidthMeasureSpec = getChildMeasureSpec(params.mLeft, params.mRight, params.width, params.leftMargin, params.rightMargin, mPaddingLeft, mPaddingRight, myWidth); int childHeightMeasureSpec = getChildMeasureSpec(params.mTop, params.mBottom, params.height, params.topMargin, params.bottomMargin, mPaddingTop, mPaddingBottom, myHeight); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); } Loading Loading @@ -910,6 +900,8 @@ public class RelativeLayout extends ViewGroup { } else if (childParams.alignWithParent && rules[LEFT_OF] != 0) { if (myWidth >= 0) { childParams.mRight = myWidth - mPaddingRight - childParams.rightMargin; } else { // FIXME uh oh... } } Loading @@ -934,16 +926,20 @@ public class RelativeLayout extends ViewGroup { } else if (childParams.alignWithParent && rules[ALIGN_RIGHT] != 0) { if (myWidth >= 0) { childParams.mRight = myWidth - mPaddingRight - childParams.rightMargin; } else { // FIXME uh oh... } } if (rules[ALIGN_PARENT_LEFT] != 0) { if (0 != rules[ALIGN_PARENT_LEFT]) { childParams.mLeft = mPaddingLeft + childParams.leftMargin; } if (rules[ALIGN_PARENT_RIGHT] != 0) { if (0 != rules[ALIGN_PARENT_RIGHT]) { if (myWidth >= 0) { childParams.mRight = myWidth - mPaddingRight - childParams.rightMargin; } else { // FIXME uh oh... } } } Loading @@ -962,6 +958,8 @@ public class RelativeLayout extends ViewGroup { } else if (childParams.alignWithParent && rules[ABOVE] != 0) { if (myHeight >= 0) { childParams.mBottom = myHeight - mPaddingBottom - childParams.bottomMargin; } else { // FIXME uh oh... } } Loading @@ -986,16 +984,20 @@ public class RelativeLayout extends ViewGroup { } else if (childParams.alignWithParent && rules[ALIGN_BOTTOM] != 0) { if (myHeight >= 0) { childParams.mBottom = myHeight - mPaddingBottom - childParams.bottomMargin; } else { // FIXME uh oh... } } if (rules[ALIGN_PARENT_TOP] != 0) { if (0 != rules[ALIGN_PARENT_TOP]) { childParams.mTop = mPaddingTop + childParams.topMargin; } if (rules[ALIGN_PARENT_BOTTOM] != 0) { if (0 != rules[ALIGN_PARENT_BOTTOM]) { if (myHeight >= 0) { childParams.mBottom = myHeight - mPaddingBottom - childParams.bottomMargin; } else { // FIXME uh oh... } } Loading