Remove the shadow of the action bar

I want to remove the shadow that appears under the appcompat action bar so that the background of the action bar is completely transparent.

This is my theme and style of action:

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

    <item name="android:actionBarStyle">@style/TransparentActionBar</item>
    <item name="android:windowActionBarOverlay">true</item>

    <!-- Support library compatibility -->
    <item name="actionBarStyle">@style/TransparentActionBar</item>
    <item name="windowActionBarOverlay">true</item>

</style>

<!-- Transparent Action Bar Style -->
<style name="TransparentActionBar"
    parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse">
    <item name="android:background">@android:color/transparent</item>

    <!-- Support library compatibility -->
    <item name="background">@android:color/transparent</item>
    <item name="elevation">0dp</item>
</style>

My minimum API level is 16

I tried several solutions for this, including:

  • Setting the height to 0dp only works for Lollipop devices.
  • I get a "resource not found" error if I try to use windowContentOverlay
  • Setting the background of the root view to a color, such as white or transparent, does not work.

I tried to get this to work on 4.4.4 to no avail. Is it possible below API level 21?

EDIT:

it turns out that windowContentOverlay only works with the android prefix:

<item name="android:windowContentOverlay">@null<item/>

( , ). , . , appcompat windowContentOverlay.

0
1

windowContentOverlay drawable, . , null, :

<item name="android:windowContentOverlay">@null</item>

<item name="windowContentOverlay">@null</item>

API 16 .

+1

Source: https://habr.com/ru/post/1656871/


All Articles