I use the new toolbar and set it as supportActionBar. My problem is that it covers my content.
Here is the code that I use to customize the toolbar.
public void setupNavBar() { mToolbar = (Toolbar) findViewById(R.id.toolbar_actionbar); if (mToolbar != null) { setSupportActionBar(mToolbar); mActionBar = getSupportActionBar(); mActionBar.setDisplayShowHomeEnabled(true); mActionBar.setDisplayShowTitleEnabled(false); } }
Styles:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> </style> <style name="ToolBarStyle" parent=""> <item name="android:elevation">5dp</item> <item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item> <item name="theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item> </style>
and layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <android.support.v7.widget.Toolbar style="@style/ToolBarStyle" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/material_blue_grey_800" android:minHeight="@dimen/abc_action_bar_default_height_material" android:id="@+id/toolbar_actionbar" /> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:background="#478" android:text="@string/hello_world" />
I thought that by calling setSupportActionbar, the system will take care of placing the content below the toolbar view, but this is not what I see.
What is the correct way to use the toolbar. I have some actions in which I want the toolbar to be transparent with the content behind it and others where I want it to be opaque with the content below.
thanks
Nath5 source share