I'm having a strange issue using TabLayout
with ViewPager
. When I swipe tabs, only a fraction of a text is shown for a short period of time. If I select tabs there is no such problem. What could be wrong?
Edit:
I have overriden the onMeasure
method of my ViewPager
:
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if(null != getAdapter()) {
int height = 0;
View child = ((FragmentPagerAdapter) getAdapter()).getItem(getCurrentItem()).getView();
if (child != null) {
child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
height = child.getMeasuredHeight();
if (android.os.Build.VERSION.SDK_INT == android.os.Build.VERSION_CODES.JELLY_BEAN && height < getMinimumHeight()) {
height = getMinimumHeight();
}
}
getLayoutParams().height = height;
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
This sets height on every ViewPager
fragment dynamically. Maybe this has something to do with the problem?