So I was having an issue adding my fragment for dialog to my activity. The fragment is a regular fragment added using
supportFragmentManager.beginTransaction().add(...).commit()
The problem is the fragment is added to the activity, but the activity's toolbar and floating action button will show on top of the fragment. I know this is because those two views are elevated to 4dp and it can be solved by changing the fragment elevation to < 4dp. My question is, is there a better way to do this? IS there a way to add a fragment on top of an activity? Or is this the way it has to be done?
Activity
<android.support.constraint.ConstraintLayout 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">
<TextView
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:elevation="4dp"
android:gravity="center"
android:text="@string/app_name"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Headline"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar"/>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_margin="24dp"/>
Dialog Fragment
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrim"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="24dp"
android:background="#40000000">
<FrameLayout
android:elevation="4dp"
android:layout_gravity="center"
android:layout_width="match_parent"
android:background="@color/white"
android:layout_height="250dp"/>