Ich habe die folgende ConstraintLayout für meine Haupttätigkeit, die für die grundlegende Navigation innerhalb der App gedacht ist.Richtige Verwendung von Android: Elevation in ConstraintLayout
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="0dp"
android:layout_marginTop="0dp"
android:background="@color/white"
app:layout_constraintBottom_toTopOf="@id/navigation"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/navigation" />
<FrameLayout
android:id="@+id/fragment_container_top"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:elevation="8dp"
/>
</android.support.constraint.ConstraintLayout>
BottomNavigationView stickt nach oben, wenn ich die entsprechenden Laschen wechseln wollen.
Das letzte FrameLayout mit der ID fragment_container_top ist für Fragmente, bei denen die BottomNavigationView ausgeblendet werden muss.
Um dies zu erreichen, setze ich die android:elevation="8dp"
, die nicht die eleganteste Option zu sein scheint. Wie sonst könnte ich den gleichen Effekt archivieren? Ich möchte nur ein Framelayout für meine äußeren Fragmente in meiner App.