Bottom navigation bar is displayed incorrectly
Here is the code:
main_activity:
<?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=".MainActivity">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:itemIconSize="34dp"
app:menu="@menu/menu">
</com.google.android.material.bottomnavigation.BottomNavigationView>
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
menu.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/main_navigation"
android:title="@string/main_navigation_title"
android:icon="@drawable/main_navigation_icon">
</item>
<item
android:id="@+id/chats_navigation"
android:title="@string/chats_navigation_title"
android:icon="@drawable/chats_navigation_icon">
</item>
<item
android:id="@+id/favorite_navigation"
android:title="@string/favorite_navigation_title"
android:icon="@drawable/favorite_naviagtion_icon">
</item>
<item
android:id="@+id/main_profile"
android:title="@string/profile_navifation_title"
android:icon="@drawable/profile_navigation_icon">
</item>
</menu>
Here’s how it appears in the preview:
(https://i.sstatic.net/FX6KqTVo.png)
Here’s how it shows up at startup on my phone:
(https://i.sstatic.net/cWWqiRBg.png)
I tried to make a fixed size, but it not only reduced the height of the navbar, but also cropped the text icons in the process.
New contributor
Deyn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.