I'm using a TextView to be viewed in ListView item, when that item is clicked I need that text to completely be viewed instead of just first 2 lines.
What I'm doing now is changing maxLines value from 2 (the initial value) to the maximum integer value.
I need this to be done with expand animation. I already know how to expand it, but I only need to find the new height such that I can simply call the expand method.
Update: I'm using this code to solve my problem, but the returned full height is smaller than the actual one. I think it's px and dp issue:
public int getFullHeight(TextView tv) {
Context context = tv.getContext();
TextView textView = new TextView(context);
textView.setText(tv.getText().toString());
textView.setTypeface(tv.getTypeface());
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, tv.getTextSize());
int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(tv.getLayoutParams().width, View.MeasureSpec.EXACTLY);
int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
textView.measure(widthMeasureSpec, heightMeasureSpec);
return textView.getMeasuredHeight();
}
Given that tv is the original TextView that's with 2 lines. If I change COMPLEX_UNIT_PX to COMPLEX_UNIT_DIP then it gets larger than the full size, with a white space at the bottom.