I want to add an icon that is used to log out, but when I include the following code the icon is displayed on the left, and I am interested in it being displayed on the right, this is my code:
// Icon
supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_cerrar)
//listener
supportActionBar?.setHomeButtonEnabled(true)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_cerrar)
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
android.R.id.home -> {
// Maneja la acción del botón en la ActionBar aquí
// Por ejemplo, para cerrar la actividad, puedes usar:
//finish()
cierre()
true
}
else -> super.onOptionsItemSelected(item)
}
}
As Pawan Harariya said, I needed to add this code:
menu_mail.xmland