Java – Removing the ActionBar shadow on Android L (API 21)

Removing the ActionBar shadow on Android L (API 21)… here is a solution to the problem.

Removing the ActionBar shadow on Android L (API 21)

I’m trying to remove the ActionBar shadow in Android L. On API 14, this code works

<style name="AppBaseTheme" parent="Theme.AppCompat.Light"/>

<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:windowContentOverlay">@null</item>                                    
</style>

But if I put the same code into /values-v21 it doesn’t work. Any ideas on how to fix it? Thank you.

Solution

On Android 5.0, the action bar uses height to provide shadows. You can programmatically remove height via getSupportActionBar().setElevation(0).

Related Problems and Solutions