I'm trying to get a drop shadow on a popup menu which is defined as given below -
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/llSortChangePopup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/backgroundColor"
android:paddingBottom="15dp"
android:paddingRight="30dp"
android:paddingLeft="20dp"
android:paddingTop="15dp"
android:elevation="2dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="20dp"
android:paddingTop="5dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_chat_bubble_outline_black_18dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text"
android:layout_marginLeft="20dp"
android:paddingTop="3dp"
android:gravity="center_vertical"
android:textColor="@color/black"
android:textSize="16dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="20dp"
android:paddingTop="5dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_chat_bubble_outline_black_18dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="More text"
android:layout_marginLeft="20dp"
android:paddingTop="3dp"
android:gravity="center_vertical"
android:textColor="@color/black"
android:textSize="16dp"/>
</LinearLayout>
</LinearLayout>
The problem is - android's design preview shows the drop shadow correctly, but when I run it on a virtual device, nothing shows up. I tried giving elevation attribute of the main layout, a vlaue 0, but to no avail. I also tried this question, I couldn't get it to work, the possible reason being my parent layout in a different xml layout file. What is wrong here?