Eu estou fazendo um app para o meu tcc e resolvi colocar um menu lateral no app, o menu funciona, mas onde fica a toolbar aparece apenas uma faixa preta sem ícone e eu coloquei um ícone de menu hambúrguer.
estou usando o android studio 1.4, a toolbar tem algum problema nessa versão?
main.java
...
Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(R.drawable.ic_menu);
}
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(menuSelection);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_drawer, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
//Clique no ícone hamburger de menu, para a abertura do drawer
case android.R.id.home:
mDrawerLayout.openDrawer(GravityCompat.START);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private NavigationView.OnNavigationItemSelectedListener menuSelection = new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
menuItem.setChecked(true);
switch (menuItem.getItemId()){
}
mDrawerLayout.closeDrawers();
return false;
}
};
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".TelaPrincipal">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="194dp"
android:id="@+id/imageView"
android:src="@drawable/logo_llga2"
android:layout_marginLeft="0dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="BEM VINDO"
android:id="@+id/tv_bem_vindo"
android:layout_gravity="center_horizontal"
android:layout_marginTop="40dp"
android:textColor="#061af6" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="criar um novo relatório"
android:id="@+id/button"
android:layout_gravity="center_horizontal"
android:layout_marginTop="40dp"
android:layout_marginRight="20dp"
android:layout_marginLeft="20dp"
android:onClick="entrar_clique" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ENVIAR RELATÓRIO"
android:id="@+id/button5"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:onClick="enviar_clique" />
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="@menu/menu_drawer"/>
</android.support.v4.widget.DrawerLayout>
style.xml
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style
name="AppTheme.AppBarOverlay"
parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style
name="AppTheme.PopupOverlay"
parent="ThemeOverlay.AppCompat.Light" />
adicionei isso tambem no AndroidManifest.xml
android:theme="@style/Theme.AppCompat.Light.NoActionBar">