Programming

Remove shadow below actionbar

25 September 2026 · 8 min read

Remove shadow below actionbar

The slight shadow cast beneath the action bar in Android applications can sometimes detract from a clean, modern UI design. Many developers seek ways to remove shadow below actionbar to achieve a flatter, more seamless aesthetic. This shadow, intended to provide a subtle visual separation between the action bar and the content below, might appear unnecessary or clash with specific design choices. Removing this shadow isn’t always straightforward and requires understanding of Android themes, styles, and potentially custom code. This guide will provide a detailed, step-by-step approach to effectively eliminate the shadow, enhancing your app’s visual appeal while maintaining compatibility across different Android versions.

Understanding the Action Bar Shadow

The shadow beneath the action bar is a default visual element introduced in later versions of Android to give depth and hierarchy to the user interface. It’s a subtle effect, but it can influence how users perceive the app’s design. Developers might want to remove elevation for several reasons, including adhering to a flat design philosophy, creating a more integrated look with the content below, or simply personal preference. The shadow’s appearance can also vary across different devices and Android versions due to manufacturer customizations and platform updates. Therefore, a consistent approach to removing it is crucial for achieving a uniform look and feel across all platforms.

The shadow is controlled by the elevation property of the action bar. Elevation, introduced in Android Lollipop (API level 21), allows developers to control the visual depth of UI elements. By default, the action bar has a certain elevation, which results in the shadow effect. To remove action bar elevation, you need to set this elevation to zero. However, simply setting the elevation to zero might not be enough in all cases, particularly on older Android versions. Older Android versions may require using different approaches like modifying the theme or using custom drawables to achieve the desired effect.

Before diving into the technical details, it’s essential to back up your project. Making incorrect modifications to themes or styles can lead to unexpected visual glitches or even app crashes. Always test your changes thoroughly on different devices and Android versions to ensure compatibility and a consistent user experience. Furthermore, consider the accessibility implications of removing the shadow. The shadow provides a visual cue that separates the action bar from the content; ensure that removing it doesn’t make the UI less usable for users with visual impairments.

Methods to Remove the Action Bar Shadow

There are several methods to remove shadow below actionbar, each with its own advantages and disadvantages. The most suitable method depends on your app’s target Android versions, your existing theme structure, and your familiarity with Android styling. Here’s a breakdown of the most common approaches:

Method 1: Using Themes and Styles (Recommended for API Level 21+): This is the preferred method for modern Android versions. You can directly modify your app’s theme to set the elevation of the action bar to zero. This approach is clean, efficient, and generally the most reliable.

Method 2: Using Custom Drawables (For Older Android Versions): On older Android versions, setting the elevation might not be sufficient. In these cases, you can override the default action bar background with a custom drawable that doesn’t include the shadow. This method involves creating a new drawable resource and applying it to the action bar’s background.

Method 3: Programmatically Setting Elevation (For Dynamic Control): If you need to dynamically control the visibility of the shadow at runtime, you can programmatically set the elevation of the action bar using Java or Kotlin code. This is useful for scenarios where the shadow should appear or disappear based on certain user actions or application states.

Featured Snippet: The most straightforward method for removing the shadow below the action bar, especially for Android Lollipop (API level 21) and above, involves modifying your app’s theme. You can achieve this by setting the elevation attribute of the android:actionBarStyle to 0dp within your theme’s style definition. This effectively removes the visual depth, resulting in a flatter, more modern look for your application’s user interface. This approach ensures a consistent appearance across different devices and provides a clean and efficient solution.

Step-by-Step Guide: Removing the Shadow Using Themes and Styles

This section provides a detailed, step-by-step guide on how to remove shadow below actionbar using themes and styles, focusing on Android Lollipop (API level 21) and above. This is the recommended approach for modern Android development.

  1. Open your styles.xml file: This file is typically located in the res/values/ directory of your Android project.
  2. Find your app’s theme: Look for the
  3. Override the actionBarStyle: Add a new element inside your theme to override the actionBarStyle. This will allow you to customize the appearance of the action bar.
  4. Set the elevation attribute: Within the overridden actionBarStyle, add another element to set the android:elevation attribute to 0dp. This will effectively remove the shadow.
  5. Clean and Rebuild your project: After making these changes, clean and rebuild your Android project to ensure that the changes are applied correctly.

Here’s an example of what your styles.xml file might look like after making these changes:

xml By following these steps, you can effectively remove action bar shadow using themes and styles. Remember to test your changes thoroughly on different devices and Android versions to ensure compatibility.

Alternative Approaches and Considerations

While using themes and styles is the preferred method, there are alternative approaches that you might need to consider, especially when dealing with older Android versions or specific design requirements. Here are some alternative approaches and important considerations:

  • Using Toolbar instead of ActionBar: The Toolbar widget provides more flexibility and control over the action bar’s appearance. You can easily set its elevation to zero or customize its background to remove the shadow. Using a Toolbar is often preferred for modern Android development due to its increased customizability.
  • Custom Drawables: On older Android versions, you might need to use custom drawables to override the default action bar background and remove the shadow. This involves creating a new drawable resource that doesn’t include the shadow and applying it to the action bar’s background.

When using custom drawables, ensure that the drawable is properly optimized for different screen densities to avoid pixelation or scaling issues. Also, consider the performance implications of using custom drawables, especially on older devices with limited processing power. For more information on creating optimized drawables, refer to the official Android documentation [Android Drawables].

  • Accessibility: Removing the shadow can impact the accessibility of your app, especially for users with visual impairments. Ensure that there is sufficient contrast between the action bar and the content below to maintain usability.
  • Testing: Always test your changes thoroughly on different devices and Android versions to ensure compatibility and a consistent user experience. Emulators and physical devices should be used for comprehensive testing.

For instance, consider a scenario where you’re developing an app with a minimalist design. The default action bar shadow might clash with the overall aesthetic. By removing elevation, you can achieve a cleaner, more modern look that aligns with the design principles. “Good design is as little design as possible,” as Dieter Rams famously said, and sometimes removing unnecessary visual elements like the action bar shadow contributes to that goal.

Infographic here
FAQ: Removing the Action Bar Shadow -----------------------------------
**Q: Why would I want to remove the shadow below the action bar?**
A: To achieve a flatter, more modern UI design, to create a more integrated look with the content below, or simply for personal preference.
**Q: What is the easiest way to remove the shadow?**
A: For Android Lollipop (API level 21) and above, the easiest way is to set the elevation attribute of the actionBarStyle to 0dp in your theme's style definition. Remember to check compatibility with older versions if needed, potentially requiring alternative methods like custom drawables.
**Q: Does removing the shadow affect accessibility?**
A: Yes, it can. Ensure there is sufficient contrast between the action bar and the content below to maintain usability for users with visual impairments.
**Q: What if setting elevation to 0dp doesn't work?**
A: On older Android versions, setting the elevation might not be sufficient. You might need to use custom drawables or other alternative approaches.
Removing the shadow below the action bar is a common customization task in Android development. By understanding the different methods and considerations, you can effectively achieve the desired look and feel for your app. Always prioritize user experience and ensure that your changes don't negatively impact accessibility. For comprehensive guidelines on Android design principles, refer to Google's Material Design documentation \[[Material Design](https://material.io/design)\]. Furthermore, explore the Android developer documentation for detailed information on themes, styles, and elevation \[[Android Developers](https://developer.android.com/)\].

Read more about Android UI customization. Removing that subtle shadow can dramatically change your app’s aesthetic, aligning it with modern design trends and your specific vision. By understanding the nuances of themes, styles, and elevation control, you’re well-equipped to create a visually appealing and user-friendly experience. Don’t be afraid to experiment and iterate, testing your changes across different devices and Android versions. Now that you understand how to remove shadow below actionbar, try it out in your project and see how it transforms your user interface. Consider exploring other UI customization options to further enhance your app’s visual appeal and user experience. Have fun developing!

Question & Answer :
I use actionbarsherlock. The piece of code below is responsible for changing it’s background to a custom one.

<style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.ActionBar"> <item name="background">@drawable/actionbar_bg</item> <item name="android:background">@drawable/actionbar_bg</item> <...> </style> <style name="Theme.MyApp" parent="@style/Theme.Sherlock.Light"> <item name="actionBarStyle">@style/Widget.Styled.ActionBar</item> <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item> <..> </style> 

And it works for actionbarsherlock (on versions below honeycomb). But in ICS I have a shadow below actionbar which I don’t want. What is the style item to make it disappear?

What is the style item to make it disappear?

In order to remove the shadow add this to your app theme:

<style name="MyAppTheme" parent="android:Theme.Holo.Light"> <item name="android:windowContentOverlay">@null</item> </style> 

UPDATE: As @Quinny898 stated, on Android 5.0 this has changed, you have to call setElevation(0) on your action bar. Note that if you’re using the support library you must call it to that like so:

getSupportActionBar().setElevation(0);