How to fix Bottom Navbar height Android Studio

  Kiến thức lập trình

I have been stuck in this for a few weeks now and I have no idea on how to solve it. I have tried to search in many different ways how to solve this issue but I haven’t found anything that it’s helpful yet.

So what is happening is that my navbar appears with double the size that it should have. I have tried to change the height manually of the navbar but it just makes the icons and text disappear.

This is my activity.xml code:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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/main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".UserActivity">

    <include
        android:id="@+id/include"
        layout="@layout/toolbar" />

    <FrameLayout
        android:id="@+id/frame_layout"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:paddingHorizontal="10dp"
        app:layout_constraintBottom_toTopOf="@+id/bottomNavigationView"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/include">
    </FrameLayout>

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottomNavigationView"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:foregroundGravity="bottom"
        android:background="@color/endColor"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:menu="@menu/bottom_navigation_menu" />

</androidx.constraintlayout.widget.ConstraintLayout>

This is my menu/bottom_navigation_menu.xml file:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:title="@string/menu_bowls"
        android:icon="@drawable/ic_list"
        android:id="@+id/bowls"/>

    <item android:title="@string/menu_feeding"
        android:icon="@drawable/ic_food"
        android:id="@+id/feeding"/>

</menu>

This is my themes.xml file:

<resources xmlns:tools="http://schemas.android.com/tools">
    <!-- Base application theme. -->
    <style name="Base.Theme.PetFeeder" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your light theme here. -->
        <!-- <item name="colorPrimary">@color/my_light_primary</item> -->
        <item name="colorPrimary">@color/startColor</item>
        <item name="colorPrimaryDark">@color/endColor</item>
    </style>

    <style name="Theme.PetFeeder" parent="Base.Theme.PetFeeder" />
    <style name="Theme.PetFeeder.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>
    <style name="Theme.PetFeeder.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
    <style name="Theme.PetFeeder.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>

Here is a reference screenshot of what I’m talking about:

enter image description here

If someone could help me it would be great because although it is not a functional bug, it annoys me that I can’t fix it and resulting on a massive navbar

New contributor

Sofia Teixeira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT