引用stackoverflow,如下
For Android 5.0,重写actiobarStyle样式,原生5.0
<item name="android:elevation">0dp</item>
and for Support library compatibility use:(v7的支持包)
<item name="elevation">0dp</item>
Example of style for a AppCompat light theme:(先重写actiobar的主题,继承你自己的主题里的actionbarStyle)
<style name="Theme.MyApp.ActionBar" parent="style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<!-- remove shadow below action bar -->
<!-- <item name="android:elevation">0dp</item> -->
<!-- Support library compatibility -->
<item name="elevation">0dp</item>
</style>
Then apply this custom ActionBar style to you app theme:
<style name="Theme.MyApp" parent="Theme.AppCompat.Light">
<item name="actionBarStyle">@style/Theme.MyApp.ActionBar</item>
</style>
For pre 5.0 Android, add this too to your app theme:(5.0之前直接在app_theme加入以下)
<!-- Remove shadow below action bar Android < 5.0 -->
<item name="android:windowContentOverlay">@null</item>