Reputation: 41
I have used android.support.design.widget.TabLayout in my app and have added 4 tabs to it. I am able to click on all the tabs even when i had already kept one of them pressed. I am wondering how i can prevent the other tabs from being clickable when any one of the tabs is already pressed. i had already tried setting split motion events to false and using touchevent method, but it didn't work. Thanks in advance.
Upvotes: 3
Views: 1025
Reputation: 1274
You need to set split motion events to false on the child container inside the TabLayout, not on the TabLayout itself. Something like this:
((ViewGroup) tabLayout.getChildAt(0)).setMotionEventSplittingEnabled(false);
Setting split motion events to false will only block multitouch from the immediate children of the ViewGroup it is set upon. TabLayout extends HorizontalScrollView and therefore contains a single child ViewGroup which, in turn, contains the actual tabs that receive the click events to be blocked.
Upvotes: 4