1

Inside values/styles.xml I have set <item name="elevation">0dp</item> to my AppTheme style. and inside values-21/styles.xml I have set <item name="android:elevation">0dp</item> and I Have also try this <item name="android:windowContentOverlay">@null</item>.I have also try to Clean the Project and Rebuild the Project. and also try to Invalidate Caches and Restart. But my Emulator still display shadow see the below screen.

Question :

How to remove that shadow below to ActionBar.

ScreenShot :

enter image description here

Harshad Pansuriya
  • 20,189
  • 8
  • 67
  • 95
  • undo all of those u describe on your question and put `android:elevation="0dp"` on your XML layout on the Toolbar element. – Budius Jun 23 '16 at 08:19
  • @Budius I am using `ActionBar` and I try this but not work. – Harshad Pansuriya Jun 23 '16 at 08:21
  • meokrvrenref rfe freiuvrwnei ewfwfijweofewfew fewfjewoifew http://stackoverflow.com/a/34348138 –  Jun 23 '16 at 08:22
  • ActionBar is deprecated. Long-live the Toolbar – Budius Jun 23 '16 at 08:27
  • @Budius Where is documentation. and set it now it's work only the shadow create problem for me. – Harshad Pansuriya Jun 23 '16 at 08:29
  • here http://android-developers.blogspot.de/2015/04/android-support-library-221.html and here https://plus.google.com/+AndroidDevelopers/posts/LNyDnnBYJ8r The G+ post title is "ActionBarActivity is dead, long live AppCompatActivity". In the blog post you'll see the comment that "ActionBarActivity has been deprecated" which you can confirm here https://developer.android.com/reference/android/support/v7/app/ActionBarActivity.html – Budius Jun 23 '16 at 08:34
  • @Budius visit this `ActionBar` is not deprecated. https://developer.android.com/reference/android/support/v7/app/ActionBar.html – Harshad Pansuriya Jun 23 '16 at 08:37
  • But as you can see, it's not an actual view. It's just an abstract class that wraps around a Toolbar contained in the activity layout. This only creates issues, like the one you're having. By ditching this abstraction layer and directly accessing the element you have much better control over it. – Budius Jun 23 '16 at 08:40
  • @Budius Ok Let's see if Someone Found solution then it's ok otherwise I go to the latest with `Toolbar`. – Harshad Pansuriya Jun 23 '16 at 08:42
  • The solution using theme will be sometihng similar to what @pdegand59 said. – Budius Jun 23 '16 at 08:42
  • @Budius see my answer below. – Harshad Pansuriya Jun 23 '16 at 10:11

3 Answers3

1

If this is a pure ActionBar, and not a Toolbar. This is how you do it :

<style name="MyAppTheme" parent="Theme.AppCompat.Light">
  <item name="actionBarStyle">@style/FlatActionBar</item>
</style>

<style name="FlatActionBar" parent="Widget.AppCompat.Light.ActionBar.Solid">
  <item name="elevation">0dp</item>
</style>
pdegand59
  • 12,776
  • 8
  • 51
  • 58
  • According to your question, you used `elevation` inside the app theme. This must be used inside a custom style applied to `actionBarStyle` – pdegand59 Jun 23 '16 at 08:28
  • @Ironman try to use different approach: StateListAnimator stateListAnimator = new StateListAnimator(); stateListAnimator.addState(new int[0], ObjectAnimator.ofFloat(appBarLayout, "elevation", 0)); appBarLayout.setStateListAnimator(stateListAnimator); – Dmitry Sep 21 '17 at 11:10
1

I don't know why elevation is not work in style. but When I set it programatically It's just work fine.

 getSupportActionBar().setElevation(0);

Output :

enter image description here

Harshad Pansuriya
  • 20,189
  • 8
  • 67
  • 95
0

Put your toolbar in this.

<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>
karanatwal.github.io
  • 3,613
  • 3
  • 25
  • 57