Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove android.widget.Toolbar shadow

Using API21+ Toolbar:

// Toolbar Toolbar toolbar = new Toolbar(this); toolbar.showOverflowMenu(); 

Would like to remove its shadow completely. setElevation(0) doesn't do anything since getElevation() already returns 0.

There is Material Design reference:

https://material.io/guidelines/layout/structure.html#structure-toolbars

There is Develop Reference:

https://developer.android.com/reference/android/widget/Toolbar.html

But I don't see any info related to the shadow. Toolbar

Question: how to remove/hide Toolbar shadow completely?

like image 344
0leg Avatar asked Apr 06 '17 12:04

0leg


People also ask

How do I get rid of the shadow bar on my Android?

By default, android provides shadow for action bar. This example demonstrates How to remove shadow below the action bar. Step 1 - Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 - Add the following code to res/layout/activity_main.

How do I remove shadow from AppBarLayout?

Simply use app:elevation="0dp" inside "AppBarLayout" to remove the shadow.


1 Answers

Use app:elevation="0dp" instead of android:elevation on your toolbar. If it is not work, put your toolbar inside of a AppBarLayout and set app:elevation="0dp":

<android.support.design.widget.AppBarLayout             android:id="@+id/appBarLayout"             android:layout_width="match_parent"             android:layout_height="wrap_content"             app:elevation="0dp">             ... </android.support.design.widget.AppBarLayout> 
like image 131
ramin eftekhari Avatar answered Sep 18 '22 16:09

ramin eftekhari