This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setSupportActionBar(findViewById(R.id.toolbar)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val drawer = findViewById(R.id.drawer) | |
val drawerToggle = ActionBarDrawerToggle(this, drawer, R.string.open, R.string.close) | |
drawer.addDrawerListener(drawerToggle) | |
drawerToggle.syncState() | |
supportActionBar?.setDisplayHomeAsUpEnabled(true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onOptionsItemSelected(item: MenuItem): Boolean { | |
return when (item.itemId) { | |
android.R.id.home -> { | |
drawer.openDrawer(GravityCompat.START) | |
true | |
} | |
else -> super.onOptionsItemSelected(item) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onBackPressed() { | |
if (drawer.isDrawerOpen(GravityCompat.START)) { | |
drawer.closeDrawer(GravityCompat.START) | |
} else { | |
super.onBackPressed() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resources> | |
<attr name="colorNavigationItem" format="color" /> | |
<attr name="colorNavigationItemSelected" format="color" /> | |
<attr name="drawableNavigationItemBackground" format="reference" /> | |
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<item name="colorNavigationItem">@color/menu_item_color_state</item> | |
<item name="colorNavigationItemSelected">@color/colorWhite</item> | |
<item name="drawableNavigationItemBackground">@drawable/menu_background_color_state</item> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<color name="colorWhite">#FFFFFF</color> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style name="Widget.Custom.NavigationView" parent="Widget.Design.NavigationView"> | |
<item name="itemIconTint">?attr/colorNavigationItem</item> | |
<item name="itemTextColor">?attr/colorNavigationItem</item> | |
<item name="itemBackground">?attr/drawableNavigationItemBackground</item> | |
</style> |