Android : ToolBar navigation button

on Wednesday, January 28, 2015


This is my Toolbar: my toolbar


And this is Gmail app Toolbar: gmail toolbar


I want to have the button which open the navigation drawer that the Gmail app has.


How can I achive that?


This is my ToolBar:



<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
app:theme="@style/ThemeOverlay.AppCompat.ActionBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/abc_action_bar_default_height_material"
android:background="#EDAA00" />


This is my theme of the app:



<style name="noActionBar" parent="Theme.AppCompat.Light.NoActionBar"/>


This is my code that create the toolbar:



Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitleTextColor(Color.WHITE);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);


Thanks in advance!


0 comments:

Post a Comment