- Set the theme as Theme.AppCompat.Light.NoActionBar (it will make toggle and title color as black, to keep them white use Theme.AppCompat.NoActionBar)
- Make a separate app_bar.xml with the code
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"></android.support.v7.widget.Toolbar>
- include this layout at the top in your main activity layout using this code
<include
android:id="@+id/app_bar"
layout="@layout/app_bar"></include>
- add reference of this toolbar in mainactivity java file
Toolbar tb=(Toolbar)findViewById(R.id.app_bar);
setSupportActionBar(tb);
getSupportActionBar().setHomeButtonEnabled(true); //to make enable back buttton and navigation drawer
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Comments
Post a Comment