remove notification bar shadow in android app

2020-05-19 07:40发布

问题:

In android, the notification bar at the top has a shadow most of the time. However, sometimes, such as when an app has it's title-bar showing, or in some other cases (such as in the twitter app or the market) that shadow effect is gone. My guess is that the shadow is supposed to be there when the content underneath can scroll.

In my app, however, the content underneath can't scroll, and I think the shadow looks bad on the top part of my logo.

Does anyone know how to disable it?

回答1:

<!-- Variation on the Light theme that turns off the title -->
<style name="Theme.IOSched" parent="android:style/Theme.Light">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowContentOverlay">@null</item>
</style>

The android:windowContentOverlay is your shadow, and setting it to @null in your theme will eliminate it. You can see this in action in the Google I|O 2010 conference app, which uses many of the same UI conventions as does the new Twitter app. However, right now, the Twitter app has not yet been open-sourced, which is why I point you to the I|O app. The code fragment above is from that app's styles.xml resource.