You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 12, 2025. It is now read-only.
Incase of large text, the text isn't shown completely in expanded state. This is still a bug in the latest version of this repository as of today and needs to be fixed in the next release @Manabu-GT . For now, following is the solution explained clearly.
SOLUTION
In ExpandableTextView class, in the onMeasure method: Cut the line
Or for ease, you can directly replace your onMeasure method with the method below.
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// If no change, measure and returnif (!mRelayout || getVisibility() ==View.GONE) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
return;
}
mRelayout =false;
// Setup with optimistic case// i.e. Everything fits. No button needed
mToggleView.setVisibility(View.GONE);
mTv.setMaxLines(Integer.MAX_VALUE);
// Measuresuper.onMeasure(widthMeasureSpec, heightMeasureSpec);
//--- Previously the mTextHeightWithMaxLines was initialized here ---// // If the text fits in collapsed mode, we are done.if (mTv.getLineCount() <= mMaxCollapsedLines) {
return;
}
// Doesn't fit in collapsed mode. Collapse text view as needed. Show// button.if (mCollapsed) {
mTv.setMaxLines(mMaxCollapsedLines);
}
mToggleView.setVisibility(View.VISIBLE);
// Re-measure with new setupsuper.onMeasure(widthMeasureSpec, heightMeasureSpec);
mTextHeightWithMaxLines = getRealTextViewHeight(mTv);
if (mCollapsed) {
// Gets the margin between the TextView's bottom and the ViewGroup's bottom
mTv.post(new Runnable() {
@Override
public void run() {
mMarginBetweenTxtAndBottom = getHeight() - mTv.getHeight();
}
});
// Saves the collapsed height of this ViewGroup
mCollapsedHeight = getMeasuredHeight();
}
}
This was also discussed in this issue here #5 but the solution wasn't explained clearly.
Incase of large text, the text isn't shown completely in expanded state. This is still a bug in the latest version of this repository as of today and needs to be fixed in the next release @Manabu-GT . For now, following is the solution explained clearly.
SOLUTION
In ExpandableTextView class, in the onMeasure method: Cut the line
and paste it right below this line
Or for ease, you can directly replace your onMeasure method with the method below.
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // If no change, measure and return if (!mRelayout || getVisibility() == View.GONE) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); return; } mRelayout = false; // Setup with optimistic case // i.e. Everything fits. No button needed mToggleView.setVisibility(View.GONE); mTv.setMaxLines(Integer.MAX_VALUE); // Measure super.onMeasure(widthMeasureSpec, heightMeasureSpec); //--- Previously the mTextHeightWithMaxLines was initialized here ---// // If the text fits in collapsed mode, we are done. if (mTv.getLineCount() <= mMaxCollapsedLines) { return; } // Doesn't fit in collapsed mode. Collapse text view as needed. Show // button. if (mCollapsed) { mTv.setMaxLines(mMaxCollapsedLines); } mToggleView.setVisibility(View.VISIBLE); // Re-measure with new setup super.onMeasure(widthMeasureSpec, heightMeasureSpec); mTextHeightWithMaxLines = getRealTextViewHeight(mTv); if (mCollapsed) { // Gets the margin between the TextView's bottom and the ViewGroup's bottom mTv.post(new Runnable() { @Override public void run() { mMarginBetweenTxtAndBottom = getHeight() - mTv.getHeight(); } }); // Saves the collapsed height of this ViewGroup mCollapsedHeight = getMeasuredHeight(); } }This was also discussed in this issue here #5 but the solution wasn't explained clearly.