I did an activity in which there is a FrameLayout and BottomNavigationBar . The problem is that the BottomNavigationBar closes the bottom of the FrameLayout . What to do? The markup code is attached below:

 <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <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/placeholder" android:layout_width="match_parent" android:layout_height="match_parent"> </FrameLayout> </android.support.constraint.ConstraintLayout> 
  • indicate margins equal to 0dp - a waste of device resources - pavlofff

2 answers 2

If you are using ConstraintLayout , then for your FrameLayout for the android:layout_height specify the value 0dp manually or in the Design edit layout mode for layout_height select match_constraint .

Also for FrameLayout add the following attributes:

 app:layout_constraintBottom_toTopOf="@+id/navigation" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" 

Thanks to this, your FrameLayout fill in the remaining space after BottomNavigationView

  • Yes it helped. But now TitleBar crawls on the elements of the screen. - mixer-09
  • @ mixer-09, supplemented the response with attributes for FrameLayout - A. Shakhov

Try changing the android: layout_heigh to 0dp and add android: layout_weight="1" for the ImageView . Taken from here .

  • one
    layout_weight is an attribute of the container LinearLayout (and not ConstraintLayout or FrameLayout) - pavlofff