I have a Toolbar in my layout and I'm setting it as action bar. The problem is that I want to change the navigation icon and add some action buttons, and none of these work.
My layout is like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.emilpana.carsharing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<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"
style="@style/Toolbar"
app:navigationIcon="@drawable/ic_car"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:titleTextAppearance="@style/ToolbarTitle" />
<ImageView
style="@style/SecondaryShadow"
android:contentDescription="@null" />
</LinearLayout>
This layout is included in my activities. I set it like this in the activity:
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
toolbar.setNavigationIcon(R.drawable.ic_car);
// getSupportActionBar().setHomeButtonEnabled(false);
getSupportActionBar().setTitle(null);
The icon is not set, it's the default hamburger. I've tried 2 styles of the App:
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:windowActionBar">false</item>
</style>
and
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
</style>
When I don't set the Toolbar as actionBar the methods above to change the navigation icon are working(adding of action buttons works too). I've tried dozens of combinations of code and layout but none worked. Does anybody has an idea why the toolbar can't be customized ? Thanks.