@@ -369,10 +369,10 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
369369 int width = 0 ;
370370 int height = 0 ;
371371
372- int widthMode = MeasureSpec .getMode (widthMeasureSpec );
373- int heightMode = MeasureSpec .getMode (heightMeasureSpec );
374- int widthSize = MeasureSpec .getSize (widthMeasureSpec );
375- int heightSize = MeasureSpec .getSize (heightMeasureSpec );
372+ final int widthMode = MeasureSpec .getMode (widthMeasureSpec );
373+ final int heightMode = MeasureSpec .getMode (heightMeasureSpec );
374+ final int widthSize = MeasureSpec .getSize (widthMeasureSpec );
375+ final int heightSize = MeasureSpec .getSize (heightMeasureSpec );
376376
377377 // Record our dimensions if they are known;
378378 if (widthMode != MeasureSpec .UNSPECIFIED ) {
@@ -637,7 +637,12 @@ private void measureChildHorizontal(View child, LayoutParams params, int myWidth
637637 mPaddingLeft , mPaddingRight ,
638638 myWidth );
639639 int childHeightMeasureSpec ;
640- if (params .width == LayoutParams .MATCH_PARENT ) {
640+ if (myHeight < 0 ) {
641+ // Negative values in a mySize/myWidth/myWidth value in RelativeLayout measurement
642+ // is code for, "we got an unspecified mode in the RelativeLayout's measurespec."
643+ // Carry it forward.
644+ childHeightMeasureSpec = MeasureSpec .makeMeasureSpec (0 , MeasureSpec .UNSPECIFIED );
645+ } else if (params .width == LayoutParams .MATCH_PARENT ) {
641646 childHeightMeasureSpec = MeasureSpec .makeMeasureSpec (myHeight , MeasureSpec .EXACTLY );
642647 } else {
643648 childHeightMeasureSpec = MeasureSpec .makeMeasureSpec (myHeight , MeasureSpec .AT_MOST );
@@ -664,6 +669,13 @@ private void measureChildHorizontal(View child, LayoutParams params, int myWidth
664669 private int getChildMeasureSpec (int childStart , int childEnd ,
665670 int childSize , int startMargin , int endMargin , int startPadding ,
666671 int endPadding , int mySize ) {
672+ if (mySize < 0 ) {
673+ // Negative values in a mySize/myWidth/myWidth value in RelativeLayout measurement
674+ // is code for, "we got an unspecified mode in the RelativeLayout's measurespec."
675+ // Carry it forward.
676+ return MeasureSpec .makeMeasureSpec (0 , MeasureSpec .UNSPECIFIED );
677+ }
678+
667679 int childSpecMode = 0 ;
668680 int childSpecSize = 0 ;
669681
0 commit comments