@@ -217,17 +217,31 @@ private void measureWithIntercept(int widthMeasureSpec, int heightMeasureSpec) {
217
217
measureChild (child , MeasureSpec .makeMeasureSpec (getScreenWidth (), MeasureSpec .EXACTLY ), MeasureSpec .makeMeasureSpec (getScreenHeight (), MeasureSpec .EXACTLY ));
218
218
} else {
219
219
final LayoutParams lp = child .getLayoutParams ();
220
+
221
+ int modeHeight = MeasureSpec .getMode (heightMeasureSpec );
222
+ if (mHelper .getMaxWidth () > 0 ) {
223
+ int sizeWidth = MeasureSpec .getSize (widthMeasureSpec );
224
+ if (sizeWidth > mHelper .getMaxWidth ()) {
225
+ widthMeasureSpec = MeasureSpec .makeMeasureSpec (mHelper .getMaxWidth (), MeasureSpec .EXACTLY );
226
+ }
227
+ }
228
+
220
229
final int childWidthMeasureSpec = getChildMeasureSpec (widthMeasureSpec ,
221
230
childLeftMargin + childRightMargin , lp .width );
222
231
int fixedHeightMeasureSpec = heightMeasureSpec ;
223
232
//针对match_parent
224
233
if (mHelper .isClipToScreen () && mHelper .isShowAsDropDown () && lp .height == LayoutParams .MATCH_PARENT ) {
225
- int mode = MeasureSpec .getMode (heightMeasureSpec );
226
234
int restContentHeight = getScreenHeight () - (mHelper .getAnchorY () + mHelper .getAnchorHeight ()) - childTopMargin - childBottomMargin ;
227
235
if (restContentHeight == 0 ) {
228
236
restContentHeight = MeasureSpec .getSize (heightMeasureSpec );
229
237
}
230
- fixedHeightMeasureSpec = MeasureSpec .makeMeasureSpec (restContentHeight , mode );
238
+ fixedHeightMeasureSpec = MeasureSpec .makeMeasureSpec (restContentHeight , modeHeight );
239
+ }
240
+ if (mHelper .getMaxHeight () > 0 ) {
241
+ int sizeHeight = MeasureSpec .getSize (fixedHeightMeasureSpec );
242
+ if (sizeHeight > mHelper .getMaxHeight ()) {
243
+ fixedHeightMeasureSpec = MeasureSpec .makeMeasureSpec (mHelper .getMaxHeight (), MeasureSpec .EXACTLY );
244
+ }
231
245
}
232
246
final int childHeightMeasureSpec = getChildMeasureSpec (fixedHeightMeasureSpec ,
233
247
childTopMargin + childBottomMargin , lp .height );
@@ -249,6 +263,14 @@ private void measureWithOutIntercept(int widthMeasureSpec, int heightMeasureSpec
249
263
if (child .getVisibility () != GONE ) {
250
264
if (child == mTarget ) {
251
265
final LayoutParams lp = child .getLayoutParams ();
266
+
267
+ if (mHelper .getMaxWidth () > 0 ) {
268
+ int sizeWidth = MeasureSpec .getSize (widthMeasureSpec );
269
+ if (sizeWidth > mHelper .getMaxWidth ()) {
270
+ widthMeasureSpec = MeasureSpec .makeMeasureSpec (mHelper .getMaxWidth (), MeasureSpec .EXACTLY );
271
+ }
272
+ }
273
+
252
274
int fixedHeightMeasureSpec = heightMeasureSpec ;
253
275
if (mHelper .isClipToScreen () && mHelper .isShowAsDropDown () && lp .height == LayoutParams .MATCH_PARENT ) {
254
276
int mode = MeasureSpec .getMode (heightMeasureSpec );
@@ -258,6 +280,14 @@ private void measureWithOutIntercept(int widthMeasureSpec, int heightMeasureSpec
258
280
}
259
281
fixedHeightMeasureSpec = MeasureSpec .makeMeasureSpec (restContentHeight , mode );
260
282
}
283
+
284
+ if (mHelper .getMaxHeight () > 0 ) {
285
+ int sizeHeight = MeasureSpec .getSize (fixedHeightMeasureSpec );
286
+ if (sizeHeight > mHelper .getMaxHeight ()) {
287
+ fixedHeightMeasureSpec = MeasureSpec .makeMeasureSpec (mHelper .getMaxHeight (), MeasureSpec .EXACTLY );
288
+ }
289
+ }
290
+
261
291
final int childHeightMeasureSpec = getChildMeasureSpec (fixedHeightMeasureSpec ,
262
292
childTopMargin + childBottomMargin , lp .height );
263
293
0 commit comments