Remove the shadow below TabLayout on android
Asked Answered
F

5

16

I'm trying to remove the shadow below tabs while using TabLayout, which is defined in a normal layout (and not as a part of a toolbar or actionbar).

Setting theme as

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

or

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

didn't work.

Also, setting elevation to 0 didn't help either.

 <android.support.design.widget.TabLayout xmlns:app="http://schemas.android.com/apk/res-auto"
                android:id="@+id/sliding_tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:background="@android:color/white"
                app:backgroundTint="@android:color/transparent"
                app:tabIndicatorColor="@android:color/transparent"
                app:tabMode="scrollable"/>
Forepleasure answered 21/7, 2015 at 15:24 Comment(4)
check out this answer linkShutter
are you serious ? that's exactly what i said i did..Forepleasure
Ok, But I tried your code and I am not getting any shadow In API 21 (Lolipop) can you tell me on which API you are testing your app and elevation works on API level 21 or higherShutter
Yes on Android L i am facing same problem and its not action bar shadow, its tablayout shadow. and <item name="android:windowContentOverlay">@null<item/> not working for me too..Votaw
D
51

I'm assuming your TabLayout is inside AppBarLayout, that shadow comes with AppBarLayout, add this app:elevation="0dp" to that widget and I believe you're good to go.

Dobruja answered 23/10, 2015 at 10:38 Comment(1)
Thanks. app:elevation="0dp" helped me to remove shadow below android.support.v7.widget.Toolbar (encapsulated in android.support.design.widget.AppBarLayout). So in consequence there is no shadow above TabLayout.Vedetta
C
8

I try app:elevation="0dp" work and android:elevation="0dp" does not work in AppBarLayout

Chirpy answered 15/1, 2016 at 7:2 Comment(0)
E
0

I had to set the elevation to 0dp and I also change the theme of AppBarLayout to @style/Base.Widget.Design.TabLayout and it worked for me

Eureka answered 27/8, 2019 at 5:42 Comment(0)
K
0

on your activity write this

supportActionBar?.elevation = 0f
Kat answered 2/7, 2022 at 4:12 Comment(1)
The OP has already mentioned that it is not using any actionBar, so this line will not execute in first place.Horney
D
-2

Put getSupportActionBar().setElevation(0); in MainActivity java file like this:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getSupportActionBar().setElevation(0);
Delly answered 12/12, 2016 at 16:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.