I’m trying to replace the default back button icon in my Android Activity’s ActionBar with a custom icon. I’m using Kotlin and have tried the following code in my Activity:
supportActionBar?.apply {
setDisplayHomeAsUpEnabled(true)
setIcon(R.drawable.ic_custom_back) // Replace with your custom icon
}
override fun onSupportNavigateUp(): Boolean {
finish()
return true
}
However, the custom icon (ic_custom_back) is not appearing. The default back button icon is still displayed.
I’ve ensured that the custom drawable is correctly placed in the res/drawable
folder and has the appropriate dimensions.