我正在使用 jetpack 导航组件来构建导航抽屉,我想更改工具栏的汉堡包图标,我尝试了很多解决方案,例如波纹管,但它们不起作用
app:navigationIcon="@drawable/menu"
Run Code Online (Sandbox Code Playgroud)
还
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.menu);
Run Code Online (Sandbox Code Playgroud)
这是我的代码
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
setSupportActionBar(toolbar)
navController=findNavController(R.id.nav_host_fragment)
appBarConfiguration=AppBarConfiguration(setOf(R.id.nav_acceuil,R.id.nav_notifications,R.id.nav_gerer,R.id.nav_deconnexion),drawer_layout)
setupActionBarWithNavController(navController,appBarConfiguration)
nav_view.setupWithNavController(navController);
}
Run Code Online (Sandbox Code Playgroud) android navigation-drawer hamburger-menu android-jetpack android-jetpack-navigation
android ×1