user13121564
user13121564

Reputation:

Bottom Navigation Icons dont show original color

I downloaded some .png files for icons. I designed a bottom navigation of material design but the colors and text is not visible. Here's a picture of icons and bottom nav. icons

home_fragment

<item
    android:id="@+id/navigation_catalogue"
    android:icon="@drawable/catalogue"
    android:title="Catalogue" />

<item
    android:id="@+id/navigation_search"
    android:icon="@drawable/search"
    android:title="Search" />

<item
    android:id="@+id/navigation_achievement"
    android:icon="@drawable/achievement"
    android:title="Achievements" />
<item
    android:id="@+id/navigation_profile"
    android:icon="@drawable/testaccount"
    android:title="Profile" />

Home Activity

public class Home extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    BottomNavigationView navView = findViewById(R.id.nav_view);
   
    navView.setItemIconTintList(null);
  
    AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
            R.id.navigation_catalogue, R.id.navigation_search, R.id.navigation_achievement,R.id.navigation_profile)
            .build();
    NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
    NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
    NavigationUI.setupWithNavController(navView, navController);
}

}

 <com.google.android.material.bottomnavigation.BottomNavigationView
    android:id="@+id/nav_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginStart="0dp"
    android:layout_marginEnd="0dp"
    android:layout_margin="10dp"
    app:itemIconTint="@null"
    style="@style/Widget.MaterialComponents.BottomNavigationView"
    android:background="?android:attr/windowBackground"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:menu="@menu/bottom_nav_menu" />

Thanks in advance

Upvotes: 2

Views: 1250

Answers (2)

saurav singh
saurav singh

Reputation: 51

In your respective java or kotlin class
binding.bottomNav.itemIconTintList = null
use this property it works for me (bottomNav will be your bottom navigation).

Upvotes: 0

Suraj Vaishnav
Suraj Vaishnav

Reputation: 8305

Add app:itemIconTint="@null" in your BottomNavigationView

Upvotes: 2

Related Questions