我下载了一些.png文件作为图标。我设计了材质设计的底部导航,但是颜色和文本不可见。这是图标和底部导航的图片。
<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" />
家庭活动
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" />
预先感谢
答案 0 :(得分:0)
在您的app:itemIconTint="@null"
中添加BottomNavigationView