Reputation: 159
I've implemented the Navigation drawer which matches the parent height. Now I think the back arrow button that shows after clicking the hamburger drawer button is actually necessary here since I can't click on it as my navigation drawer also surpasses the toolbar once it's shown.
I don't actually want that button animation, so how can I make the hamburger drawer button stay without it transforming to back arrow? I need the code and explanations. Thanks!
NavigationView
<android.support.design.widget.NavigationView
android:id="@+id/navigation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="@menu/navigation_menu"/>
MainActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
...
// Drawer
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.activity_main);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, R.string.navigation_open, R.string.navigation_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
}
Upvotes: 5
Views: 1593
Reputation: 62189
On Google IO 2017 this API was introduced, which is available from support library version 25.3.0.
// Install drawer toggle
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout,
R.string.drawer_open, R.string.drawer_close);
// Disable animation
drawerToggle.setDrawerSlideAnimationEnabled(false);
This will make the drawer arrow not to be animated.
See video at exact minute.
Upvotes: 4
Reputation: 483
In your layout where Drawer Layout is there, have a android.support.v7.widget.Toolbar over their and inside toolbar put a ImageView at left and onclicking that imageview check if drawer is open, then close it and vice-versa.
Like this :
if (drawerLayout.isDrawerOpen(GravityCompat.START)) {
drawerLayout.closeDrawer(GravityCompat.START);
} else {
drawerLayout.openDrawer(GravityCompat.START);
}
Upvotes: 0