Reputation: 3572
My menu is not sticking to the bottom. I have a menu, in a BottomNavigationView. The navigation view is included in a layout. I tried with setting gravity to bottom, setting constraints, alignparentbottom, still it is showing at the top of the layout. Below is the code for my menu, navigation, and my layout.
I added a picture to illustrate the problem:
My Menu. It has a few menuitems:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<--- items here --->
</menu>
My BottomNavigationView:
<android.support.design.widget.BottomNavigationView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="56dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:menu="@menu/nav_menu"
android:id="@+id/bottom_menu_layout"
android:layout_gravity="bottom">
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="#D3D3D3" />
</android.support.design.widget.BottomNavigationView>
my layout file:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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:include="http://schemas.android.com/apk/res-auto">
<TextView
android:id="@+id/mainlayouttext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="@string/maintextview"
include:layout_constraintBottom_toBottomOf="parent"
include:layout_constraintEnd_toEndOf="parent"
include:layout_constraintStart_toStartOf="parent"
include:layout_constraintTop_toTopOf="parent" />
<include layout="@layout/meny_bottom_layout" />
</android.support.constraint.ConstraintLayout>
Upvotes: 2
Views: 1606
Reputation: 844
<android.support.design.widget.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:menu="@menu/bottombar_menu"/>
Create a new bottombar_menu.xml under …res/menu/.
bottombar_menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/bottombaritem_calls"
android:icon="@drawable/ic_call_24dp"
android:title="Calls"
app:showAsAction="ifRoom"/>
</menu>
you can try like this
Upvotes: 1
Reputation: 157447
your include does not specify any constraints
. If I were in you, I would try something like
<include
android:layout_height="0dp"
android:layout_width="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
layout="@layout/meny_bottom_layout"/>
android:layout_height
and android:layout_width
are mandatory if you want the other included parameter to be taken in consideration
Upvotes: 1