Brad
Brad

Reputation: 137

Get rid of ActionBar shadow over SlidingTabLayout

I'm porting my app to appcompat21, using SlidingTabLayout for tabs in an ActionBarActivity. The Action bar is casting a shadow over the tab strip, and I can't figure out how to get rid of it:enter image description here

Here's what I have:

 <style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar">
     <item name="background">@color/app_primary</item>
     <item name="android:background">@color/app_primary</item>
     <item name="backgroundSplit">@color/black</item>
     <item name="android:backgroundSplit">@color/black</item>
     <item name="android:elevation">0dp</item>
 </style>

I've also tried

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

I got the shadow under the tab bar by setting its elevation in the layout file, but now I have two shadows... Any idea how to fix this?

Upvotes: 7

Views: 2839

Answers (4)

Harshit Pethani
Harshit Pethani

Reputation: 11

Add app:elevation="0dp" on .support.design.widget.AppBarLayout. This will solve the issue.

Upvotes: 1

You could also try putting

<item name="elevation">0dp</item>

without the "android:", this would spare you the pain of setting the elevation every time you start an activity

Upvotes: 0

DJTN
DJTN

Reputation: 52

When working with "Elevation", objects can be different elevations from one another, giving shadows to anything underneath them.

If you set your toolbar and the tabs layout the same elevation it will fix the issue.

Upvotes: 2

Jared Burrows
Jared Burrows

Reputation: 55525

For some reason, this did not work for as well:

<item name="android:elevation">0dp</item>

and:

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

I am currently using, for ActionBar:

this.getSupportActionBar().setElevation(0);

Upvotes: 9

Related Questions