I'm using this SO answer to simulate elevation on my BottomSheetDialogFragment because elevation doesn't work with it.
https://stackoverflow.com/a/40927770/11110509
However when I add that fake shadow, there is unwanted white space unlike that SO answer. How do I remove it?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="300dp"
android:elevation="6dp">
<View
android:id="@+id/fragplaces_top_shadow"
android:layout_width="match_parent"
android:layout_height="16dp"
android:background="@drawable/shadow_dialog_places_top"/>
<TextView
android:id="@+id/fragplaces_app_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Places near me"
android:textColor="@color/colorWhite"
android:textStyle="bold"
android:layout_alignParentStart="true"
android:layout_below="@+id/fragplaces_top_shadow"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:background="@color/standardBlue"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/fragadd_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/fragplaces_app_name"
android:background="@color/colorWhite"/>
</RelativeLayout>
Heres the faux shadow:
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="90"
android:endColor="@android:color/transparent"
android:startColor="#64000000"/>
</shape>
Adding a transparent background to the parent layout doesn't work either:
android:background="@android:color/transparent"
How do I remove the unwanted white space in my fake shadow?
Inside your dialog set up, try setting the background to transparent:
Notice that you apply it to the view not the dialog.