@@ -76,7 +76,7 @@ public DynamicLayout(CharSequence base, CharSequence display,
7676 boolean includepad ,
7777 TextUtils .TruncateAt ellipsize , int ellipsizedWidth ) {
7878 this (base , display , paint , width , align , TextDirectionHeuristics .FIRSTSTRONG_LTR ,
79- spacingmult , spacingadd , includepad , ellipsize , ellipsizedWidth );
79+ spacingmult , spacingadd , includepad , ellipsize , ellipsizedWidth , Integer . MAX_VALUE );
8080 }
8181
8282 /**
@@ -93,7 +93,7 @@ public DynamicLayout(CharSequence base, CharSequence display,
9393 int width , Alignment align , TextDirectionHeuristic textDir ,
9494 float spacingmult , float spacingadd ,
9595 boolean includepad ,
96- TextUtils .TruncateAt ellipsize , int ellipsizedWidth ) {
96+ TextUtils .TruncateAt ellipsize , int ellipsizedWidth , int maxLines ) {
9797 super ((ellipsize == null )
9898 ? display
9999 : (display instanceof Spanned )
@@ -135,6 +135,8 @@ public DynamicLayout(CharSequence base, CharSequence display,
135135 mEllipsize = true ;
136136 }
137137
138+ mMaxLines = maxLines ;
139+
138140 // Initial state is a single line with 0 characters (0 to 0),
139141 // with top at 0 and bottom at whatever is natural, and
140142 // undefined ellipsis.
@@ -283,7 +285,7 @@ private void reflow(CharSequence s, int where, int before, int after) {
283285 reflowed .generate (text , where , where + after ,
284286 getPaint (), getWidth (), getAlignment (), getTextDirectionHeuristic (),
285287 getSpacingMultiplier (), getSpacingAdd (),
286- false , true , mEllipsizedWidth , mEllipsizeAt );
288+ false , true , mEllipsizedWidth , mEllipsizeAt , mMaxLines );
287289 int n = reflowed .getLineCount ();
288290
289291 // If the new layout has a blank line at the end, but it is not
@@ -488,6 +490,8 @@ public int getEllipsisCount(int line) {
488490
489491 private int mTopPadding , mBottomPadding ;
490492
493+ private int mMaxLines ;
494+
491495 private static StaticLayout sStaticLayout = new StaticLayout (null );
492496
493497 private static final Object [] sLock = new Object [0 ];
0 commit comments