0

My tab won't show any shadow underneath, what is wrong with my code :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#171717"
    android:orientation="vertical">

    <android.support.design.widget.TabLayout
        android:id="@+id/tabLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="?actionBarSize"
        android:elevation="10dp"
        app:tabBackground="@color/tabBackground"
        app:tabGravity="fill"
        app:tabIndicatorColor="#425ced"
        app:tabIndicatorHeight="4dp"
        app:tabMode="fixed"
        app:tabSelectedTextColor="#425ced"
        app:tabTextColor="#e5e5e5"
        >
    </android.support.design.widget.TabLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewPager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:elevation="0dp"/>
</LinearLayout>
AskNilesh
  • 67,701
  • 16
  • 123
  • 163
Troll PC
  • 85
  • 1
  • 1
  • 7
  • Which version of support library are you using? 27.0.0 has just resolved most of elevation problems, older version does not support elevation for al components – Mahdi Rajabi Aug 21 '18 at 08:33
  • [see your answer here ](https://stackoverflow.com/a/43407492/7707187) it worked for me – kfir88 Aug 21 '18 at 08:44

2 Answers2

1

Use

app:elevation="10dp"

Instead of

android:elevation="10dp"

Try this

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#171717"
    android:orientation="vertical">

    <android.support.design.widget.TabLayout
        android:id="@+id/tabLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="?actionBarSize"
        app:elevation="10dp"
        app:tabBackground="@color/tabBackground"
        app:tabGravity="fill"
        app:tabIndicatorColor="#425ced"
        app:tabIndicatorHeight="4dp"
        app:tabMode="fixed"
        app:tabSelectedTextColor="#425ced"
        app:tabTextColor="#e5e5e5"
        >
    </android.support.design.widget.TabLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewPager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:elevation="0dp"/>
</LinearLayout>
AskNilesh
  • 67,701
  • 16
  • 123
  • 163
1

you shouldn't use

android:elevation="10dp"

use this one

app:elevation="10dp"

and upgrade your support library to last version to have a better performance. good luck