material-components-android
material-components-android copied to clipboard
[TabLayout] Can't customize TabView click listener
Description:
I have a business logic in the app to perform a certain validation when the TabView is clicked. Due to the current TabLayout implementation, I can't prevent tab selection when the tab is clicked.
Expected behavior:
We should have an option to control this behavior.
Source code: TabLayout.java
@Override
public boolean performClick() {
final boolean handled = super.performClick();
if (tab != null) {
if (!handled) {
playSoundEffect(SoundEffectConstants.CLICK);
}
tab.select();
return true;
} else {
return handled;
}
}
Minimal sample app repro:
- Create Activity/Fragment with TabLayout and a few TabView items.
- Click on the tab
Material Library version: 1.11.0