【发布时间】:2018-07-25 20:59:42
【问题描述】:
所以我在将我的对话片段添加到我的活动时遇到了问题。该片段是使用
添加的常规片段supportFragmentManager.beginTransaction().add(...).commit()
问题是片段被添加到活动中,但活动的工具栏和浮动操作按钮将显示在片段顶部。我知道这是因为这两个视图被提升到 4dp 并且可以通过将片段高度更改为
活动
<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"/>
对话框片段
<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"/>
【问题讨论】:
标签: android android-fragments android-elevation