Reputation: 793
I would like to set a constraint for a FrameLayout to the top of the Navigation bar in Android.
Here is the code of the XML layout file:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
app:labelVisibilityMode="labeled"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorGreen"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/bottom_navigation"
app:itemIconTint="@color/colorPrimaryDark"
app:itemTextColor="@color/colorAccent"
/>
<FrameLayout
android:id="@+id/container_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toTopOf="@+id/bottom_navigation" />
</androidx.constraintlayout.widget.ConstraintLayout>
I tried it with the line:
app:layout_constraintBottom_toTopOf="@+id/bottom_navigation
but it the resulting layout does not seem to look rigth. Here you can see a screenshot: Do you have any ideas what I should do? I'd appreciate every comment and would be thankful for your help.
Upvotes: 0
Views: 1661
Reputation: 130
What about using
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/bottom_navigation"
app:layout_constraintTop_toTopOf="parent"
In your FrameLayout
Upvotes: 1