Removing a shadow from a toolbar when opening a navigation box - material support library support

I embed Material Design in my application, which has a navigation box. Among all the various Nav implementations. Box and toolbar with material design ( see. This post ); I decided that the application should look just like the ICS / Halo design, and pulled out a Nav box under the toolbar. The problem is that the toolbar fades with shadow, like any activity when the navigation box is open. How can I color the toolbar? If you see the image in the post I linked above, I'm after # 6, 3 or 5, but now I like # 9 more.

Example (from the post above):

What I need (no shadow on the toolbar):

enter image description here

What I'm getting right now (the toolbar gets dark when the navigation box is open):

enter image description here

Here is the code for my main XML action:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:context="com.funkhaus.navdrawer.app.MainActivity"> <!-- As the main content view, the view below consumes the entire space available using match_parent in both dimensions. --> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent"> <!-- We use a Toolbar so that our drawer can be displayed in front of the action bar; Added for Material Design --> <android.support.v7.widget.Toolbar android:id="@+id/my_awesome_toolbar" android:layout_height="wrap_content" android:layout_width="match_parent" android:minHeight="?attr/actionBarSize" android:background="?attr/colorPrimary" /> <FrameLayout android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="?attr/actionBarSize" /> </FrameLayout> <fragment android:id="@+id/navigation_drawer" android:layout_width="@dimen/navigation_drawer_width" android:layout_height="match_parent" android:layout_marginTop="?attr/actionBarSize" android:fitsSystemWindows="true" android:layout_gravity="start" android:name="com.funkhaus.brewwerks.NavigationDrawerFragment" /> 

The notable part is that <FrameLayout> , whose identifier is 'container' , where all my fragments are bloated, and its marginTop been set to the height of the toolbar, so its contents will be below the toolbar. Similarly, a navigation box fragment also has its marginTop set to the height of the toolbar so that it slides lower.

+7
android material-design
source share
2 answers

Thanks to @alanv, I fixed my problem.

My post above shows my activity_main.xml code; I simplified this by removing the toolbar view and removing the marginTop formatting:

 <android.support.v4.widget.DrawerLayout 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" android:fitsSystemWindows="true" tools:context="com.funkhaus.navdrawer.app.MainActivity"> <!-- As the main content view, the view below consumes the entire space available using match_parent in both dimensions. --> <FrameLayout android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" /> <fragment android:id="@+id/navigation_drawer" android:layout_width="@dimen/navigation_drawer_width" android:layout_height="match_parent" android:fitsSystemWindows="true" android:layout_gravity="start" android:name="com.funkhaus.brewwerks.NavigationDrawerFragment" /> </android.support.v4.widget.DrawerLayout> 

I created a toolbar.xml , which I now setContentView () is included in my main Office, that <include> activity_main.xml above:

 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="vertical"> <!-- We use a Toolbar so that our drawer can be displayed in front of the action bar; Added for Material Design --> <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/my_awesome_toolbar" android:layout_height="wrap_content" android:layout_width="match_parent" android:minHeight="?attr/actionBarSize" android:background="?attr/colorPrimary" /> <include android:id="@+id/drawer_layout" layout="@layout/activity_main" /> </LinearLayout> 

Finally, in my onCreate() activity, I setContentView() on toolbar.xml :

 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.toolbar); // Rest of code here.... 
+9
source share
 You do it in the same xml like this, This is for underlying toolbar navigation like play store app design <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.ccas.roadsideconnect.BaseFragmentActivity"> <android.support.v4.widget.DrawerLayout android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" > <FrameLayout android:id="@+id/main_fragment_container" android:layout_marginTop="?attr/actionBarSize" android:layout_width="match_parent" android:layout_height="match_parent" /> <FrameLayout android:id="@+id/navigation_drawer" android:layout_width="@dimen/navigation_drawer_width" android:layout_height="match_parent" android:layout_gravity="start" tools:layout="@layout/fragment_navigation_drawer" /> </android.support.v4.widget.DrawerLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="@drawable/img_actionbar_white_sm" android:gravity="top" android:minHeight="58.0dip" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" app:theme="@style/ThemeOverlay.AppCompat.ActionBar" /> </LinearLayout> </FrameLayout> 

The code below is for overlaying navigation on a toolbar, such as the design of APP Gmail.

 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.ccas.roadsideconnect.BaseFragmentActivity"> <android.support.v4.widget.DrawerLayout android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" > <FrameLayout android:id="@+id/main_fragment_container" android:layout_marginTop="?attr/actionBarSize" android:layout_width="match_parent" android:layout_height="match_parent" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="@drawable/img_actionbar_white_sm" android:gravity="top" android:minHeight="58.0dip" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" app:theme="@style/ThemeOverlay.AppCompat.ActionBar" /> </LinearLayout> <FrameLayout android:id="@+id/navigation_drawer" android:layout_width="@dimen/navigation_drawer_width" android:layout_height="match_parent" android:layout_gravity="start" tools:layout="@layout/fragment_navigation_drawer" /> </android.support.v4.widget.DrawerLayout> </FrameLayout> 
+2
source share

All Articles