I'm using code from this answer. And I'm trying to disable the elevation of the toolbar when collapsed. I tried putting android:elevation="0dp"
to all xml tags but it just didn't work out. Any suggestion?
Asked
Active
Viewed 5,640 times
8

Ahmed Alnabhan
- 608
- 1
- 9
- 13

Hendra Anggrian
- 5,780
- 13
- 57
- 97
-
Target Api >=21 or <21 ? Take a look here :http://stackoverflow.com/questions/26575197/no-shadow-by-default-on-toolbar – Andre Classen Dec 28 '15 at 13:45
-
1holy bejesus using app:elevation instead of android:elevation actually works. Why did you remove your comment? Please post it as an answer – Hendra Anggrian Dec 28 '15 at 13:49
-
Hi Hendra, Did you ever got to solve this? I've tried setting app:elevation="0dp" in the collapsingToolbarLayout but it doesn't seem to have any effect – Nemesis Feb 17 '16 at 14:14
-
@Nemesis you're not supposed to put app:elevation on CollapsingToolbarLayout, it is not the one who actually have an elevation attribute. You put it in AppBarLayout, which is a direct parent of CollapsingToolbarLayout. Let me know how it works for you or if you need an example code. – Hendra Anggrian Feb 18 '16 at 16:38
-
@HendraAnggrian great! That solved the issue, I don't know how I didn't come up with this earlier, now it seems so obvious. – Nemesis Feb 19 '16 at 13:05
-
@Nemesis no worries, happy coding! – Hendra Anggrian Feb 19 '16 at 17:02
2 Answers
31
Setting app:elevation="0dp"
on AppBarLayout
does the job.

Hendra Anggrian
- 5,780
- 13
- 57
- 97
-
-
-
3Those who tried and did not work - make sure you use `app` annotation and not `android` – Alon Shlider Feb 24 '20 at 10:34