I need to change the background color of the selected tab when the user click on it to white.
Those two attempts are not working (the first is commented)
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
// LinearLayout parent = new LinearLayout(getApplicationContext());
// parent.setLayoutParams(new LinearLayout.LayoutParams(LinearLayoutCompat.LayoutParams.MATCH_PARENT, LinearLayoutCompat.LayoutParams.WRAP_CONTENT));
// parent.setBackgroundColor(getResources().getColor(R.color.white));
// tab.setCustomView(parent);
tabLayout.getTabAt(tabLayout.getSelectedTabPosition()).setBackgroundColor(getResources().getColor(R.color.white));
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});