List of usage examples for android.widget TextView getMaxHeight
public int getMaxHeight()
From source file:Main.java
public static void animateTextViewMaxLinesChange(final TextView textView, final int maxLines, final int duration) { final int startHeight = textView.getMeasuredHeight(); textView.setMaxLines(maxLines);/*from w w w .jav a 2s . c o m*/ textView.measure(View.MeasureSpec.makeMeasureSpec(textView.getWidth(), View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); final int endHeight = textView.getMeasuredHeight(); ObjectAnimator animation = ObjectAnimator.ofInt(textView, MAX_HEIGHT_ATTR, startHeight, endHeight); animation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (textView.getMaxHeight() == endHeight) { textView.setMaxLines(maxLines); } } } ); animation.setDuration(duration).start(); }