Open subodh-malgonde opened 9 years ago
Re-opening this issue with the proper formatting for the earlier comment.
I have the same issue. I think it has something with onMeasure method in TabPageIndicator . It resizes the view when there are smaller tabs to match screen width, but sometimes what you explained is happening. Method:
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
final boolean lockedExpanded = widthMode == MeasureSpec.EXACTLY;
setFillViewport(lockedExpanded);
final int childCount = mTabLayout.getChildCount();
if (childCount > 1 && (widthMode == MeasureSpec.EXACTLY || widthMode == MeasureSpec.AT_MOST)) {
if (childCount > 2) {
mMaxTabWidth = (int)(MeasureSpec.getSize(widthMeasureSpec) * 0.4f);
} else {
mMaxTabWidth = MeasureSpec.getSize(widthMeasureSpec) / 2;
}
} else {
mMaxTabWidth = -1;
}
final int oldWidth = getMeasuredWidth();
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
final int newWidth = getMeasuredWidth();
if (lockedExpanded && oldWidth != newWidth) {
// Recenter the tab display if we're at a new (scrollable) size.
setCurrentItem(mSelectedTabIndex);
}
}
I changed
final boolean lockedExpanded = widthMode == MeasureSpec.EXACTLY;
to
final boolean lockedExpanded = widthMode == MeasureSpec.UNSPECIFIED;
to go around this problem, but still this is not the best solution...
Sometimes the page title in TabPageIndicator is split into 2 lines, sometimes as whole words and sometimes as broken words. Here are some screen shots
1) Split into 2 lines - broken words
2) Split into 2 lines - whole words
3) Not split into 2 lines
Here is my layout code:
Here is my style code:
Can anyone tell me whats wrong here which causes the page titles to randomly split into 2 lines and sometimes not?