@@ -47,6 +47,7 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo
4747 private OnBouncerStateChangedListener mBouncerListener ;
4848
4949 private final Rect mTempRect = new Rect ();
50+ private final Context mContext ;
5051
5152 private final OnClickListener mScrimClickListener = new OnClickListener () {
5253 @ Override
@@ -66,6 +67,8 @@ public MultiPaneChallengeLayout(Context context, AttributeSet attrs) {
6667 public MultiPaneChallengeLayout (Context context , AttributeSet attrs , int defStyleAttr ) {
6768 super (context , attrs , defStyleAttr );
6869
70+ mContext = context ;
71+
6972 final TypedArray a = context .obtainStyledAttributes (attrs ,
7073 R .styleable .MultiPaneChallengeLayout , defStyleAttr , 0 );
7174 mOrientation = a .getInt (R .styleable .MultiPaneChallengeLayout_orientation ,
@@ -173,6 +176,8 @@ protected void onMeasure(int widthSpec, int heightSpec) {
173176 throw new IllegalArgumentException (
174177 "MultiPaneChallengeLayout must be measured with an exact size" );
175178 }
179+ float squashedLayoutThreshold =
180+ mContext .getResources ().getDimension (R .dimen .kg_squashed_layout_threshold );
176181
177182 final int width = MeasureSpec .getSize (widthSpec );
178183 final int height = MeasureSpec .getSize (heightSpec );
@@ -208,28 +213,32 @@ protected void onMeasure(int widthSpec, int heightSpec) {
208213 mUserSwitcherView = child ;
209214
210215 if (child .getVisibility () == GONE ) continue ;
211-
212- int adjustedWidthSpec = widthSpec ;
213- int adjustedHeightSpec = heightSpec ;
214- if (lp .maxWidth >= 0 ) {
215- adjustedWidthSpec = MeasureSpec .makeMeasureSpec (
216- Math .min (lp .maxWidth , MeasureSpec .getSize (widthSpec )),
217- MeasureSpec .EXACTLY );
218- }
219- if (lp .maxHeight >= 0 ) {
220- adjustedHeightSpec = MeasureSpec .makeMeasureSpec (
221- Math .min (lp .maxHeight , MeasureSpec .getSize (heightSpec )),
222- MeasureSpec .EXACTLY );
223- }
224- // measureChildWithMargins will resolve layout direction for the LayoutParams
225- measureChildWithMargins (child , adjustedWidthSpec , 0 , adjustedHeightSpec , 0 );
226-
227- // Only subtract out space from one dimension. Favor vertical.
228- // Offset by 1.5x to add some balance along the other edge.
229- if (Gravity .isVertical (lp .gravity )) {
230- heightUsed += child .getMeasuredHeight () * 1.5f ;
231- } else if (Gravity .isHorizontal (lp .gravity )) {
232- widthUsed += child .getMeasuredWidth () * 1.5f ;
216+ if (height < squashedLayoutThreshold ) {
217+ int zero = MeasureSpec .makeMeasureSpec (0 , MeasureSpec .EXACTLY );
218+ measureChild (child , zero , zero );
219+ } else {
220+ int adjustedWidthSpec = widthSpec ;
221+ int adjustedHeightSpec = heightSpec ;
222+ if (lp .maxWidth >= 0 ) {
223+ adjustedWidthSpec = MeasureSpec .makeMeasureSpec (
224+ Math .min (lp .maxWidth , MeasureSpec .getSize (widthSpec )),
225+ MeasureSpec .EXACTLY );
226+ }
227+ if (lp .maxHeight >= 0 ) {
228+ adjustedHeightSpec = MeasureSpec .makeMeasureSpec (
229+ Math .min (lp .maxHeight , MeasureSpec .getSize (heightSpec )),
230+ MeasureSpec .EXACTLY );
231+ }
232+ // measureChildWithMargins will resolve layout direction for the LayoutParams
233+ measureChildWithMargins (child , adjustedWidthSpec , 0 , adjustedHeightSpec , 0 );
234+
235+ // Only subtract out space from one dimension. Favor vertical.
236+ // Offset by 1.5x to add some balance along the other edge.
237+ if (Gravity .isVertical (lp .gravity )) {
238+ heightUsed += child .getMeasuredHeight () * 1.5f ;
239+ } else if (Gravity .isHorizontal (lp .gravity )) {
240+ widthUsed += child .getMeasuredWidth () * 1.5f ;
241+ }
233242 }
234243 } else if (lp .childType == LayoutParams .CHILD_TYPE_SCRIM ) {
235244 setScrimView (child );
0 commit comments