BottomNavigationView Original icon color I have found it here that it is possible to retain the same icon color. But is it possible to keep it only when the icon is selected and keep a different greyish color for a non-selected tab? This is my code for changing the icon color.
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:color="@color/colorSecondary"
android:state_checked="true"/>
<item
android:color="#bebebe"
android:state_checked="false"/>
Here in state_checked I tried giving @null but it just makes the icons pinkish. I want to retain the icon color when it is checked. Is it possible?
Note: I have also tried using bNavigationView.setIconTintList(null); which changes all the icon color to original.
public class MainActivity extends AppCompatActivity {
Toolbar toolbar;
BottomNavigationView bNavigationView;
BottomNavigationView.OnNavigationItemSelectedListener
mOnNavigationItemSelectedListener
= new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
switch (item.getItemId()) {
case R.id.navigation_account:
// AS gives me an error here saying setItemIconTintList cannot be applied to (int,null)
bNavigationView.setItemIconTintList(0,null);
fragmentTransaction.replace(R.id.content,new AccountFragment()).commit();
break;
case R.id.navigation_technical:
fragmentTransaction.replace(R.id.content,new TechnicalEventsFragment()).commit();
break;
case R.id.navigation_corporate:
fragmentTransaction.replace(R.id.content,new CorporateEventsFragment()).commit();
break;
case R.id.navigation_cultural:
fragmentTransaction.replace(R.id.content,new CulturalEventsFragment()).commit();
break;
case R.id.navigation_dashboard:
fragmentTransaction.replace(R.id.content,new DashboardFragment()).commit();
break;
}
return true;
}
};