如何移除Android ActionBar底部边框?已解决:修改Activity主题
It sounds like you hit a common gotcha when trying to remove the ActionBar's bottom border/shadow—let’s walk through the solution that worked for you, since it’s easy to mix up which theme controls this element:
First, you mentioned two methods that didn’t work at first:
- Calling
setElevation(0)programmatically - Adding
<item name="android:windowContentOverlay">@null</item>to your ActionBar-specific theme
The root issue was misidentifying where the border is styled: it’s not part of the ActionBar’s theme, but your Activity’s theme.
The Working Fix
To eliminate the bottom border, you need to add the windowContentOverlay attribute to your Activity’s style definition (not the nested ActionBar theme):
<!-- For AppCompat-based themes --> <item name="windowContentOverlay">@null</item> <!-- For older Android themes using the android namespace --> <item name="android:windowContentOverlay">@null</item>
Once you apply this change to your Activity’s theme, the bottom border will disappear completely. This works because the shadow/border is actually drawn by the window content overlay tied to the Activity, not the ActionBar itself.
内容的提问来源于stack exchange,提问作者JMR

