I have a working TabLayout, and I am trying to update the tab text color dynamically, when changing tabs. To do this, I call the setTabTextColors()
method on my TabLayout as such:
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
tabLayout.setTabTextColors(newColorStateList);
}
(...)
});
For some reason, the text color doesn't update. Does anyone know how to update the tab text color dynamically?
I am using the Design Support Library v22.2.0.
TabLayout
has a method like this -
setTabTextColors(int normalColor, int selectedColor)
Remember, that int
is not color resource value but int
parsed from hex
Ex:
tabLayout.setTabTextColors(Color.parseColor("#D3D3D3"),Color.parseColor("#2196f3"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With