Disable TabLayout
Solution 1:
I had the same problem and I solved it disabling touch event on tabs with the following code:
LinearLayout tabStrip = ((LinearLayout)mTabLayout.getChildAt(0));
for(int i = 0; i < tabStrip.getChildCount(); i++) {
tabStrip.getChildAt(i).setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
}
Solution 2:
I found a similar answer that is a little more simple and also allows you to re-enable the tabs later if you wanted to without having to deal with overriding the onTouch event.
TabLayout tabLayout = (TabLayout) mParentView.findViewById(R.id.my_tabs);
LinearLayout tabStrip = ((LinearLayout)tabLayout.getChildAt(0));
tabStrip.setEnabled(false);
for(int i = 0; i < tabStrip.getChildCount(); i++) {
tabStrip.getChildAt(i).setClickable(false);
}
And if you want to re-enable the tabs just set tabStrip.setEnabled and setClickable for the child elements to true
LinearLayout tabStrip = ((LinearLayout)tabLayout.getChildAt(0));
tabStrip.setEnabled(true);
for(int i = 0; i < tabStrip.getChildCount(); i++) {
tabStrip.getChildAt(i).setClickable(true);
}