I'm trying to add a BottomMenu to my app but it doesn't appear. I have tried changing the background color, adding the wight property but nothing works.
My activity
<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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottomNavigationView"
android:layout_width="match_parent"
android:layout_height="#dimen/_40sdp"
android:background="#fff"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="#menu/bottom_menu" />
</androidx.constraintlayout.widget.ConstraintLayout>
bottommenu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/dateAndTimeFragment"
android:title="Home"
android:icon="#drawable/ic_baseline_home_24"
/>
<item
android:id="#+id/settingsFragment"
android:title="SMS"
android:icon="#drawable/ic_baseline_settings_24"
/>
<item
android:id="#+id/messagesFragment"
android:title="CONFIGURATION"
android:icon="#drawable/ic_baseline_settings_24"
/>
</menu>
Here you can see how it does not show anything
Related
bottom Navigation bar is long seems like a space is excreted, i tried to solve this problem a days.
This is the problem
:
This is the xml code :
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".Home_activity">
<!-- 813dp -->
<fragment
android:id="#+id/fragment"
android:name="com.anonymous.nr_chemistryteam.BlankFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.google.android.material.bottomappbar.BottomAppBar
android:id="#+id/bottomAppBar"
style="#style/Widget.MaterialComponents.BottomAppBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:backgroundTint="#color/white"
android:theme="#style/AppThemeMaterial2"
app:fabCradleMargin="8dp"
app:fabCradleRoundedCornerRadius="50dp"
app:fabCradleVerticalOffset="6dp">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/homeNvBottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:background="#drawable/empty_background"
app:menu="#menu/bottom_menu" />
</com.google.android.material.bottomappbar.BottomAppBar>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/floatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#ff5e00"
android:src="#drawable/ic_cart"
app:fabCustomSize="72dp"
app:layout_anchor="#id/bottomAppBar"
app:maxImageSize="34dp" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
This is the menu xml code :
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/home_page2"
android:icon="#drawable/ic_home2"
android:title="Home" />
<item
android:id="#+id/message_page2"
android:icon="#drawable/ic_message1"
android:title="Message" />
<item
android:id="#+id/placeholder"
android:checkable="false"
android:title="" />
<item
android:id="#+id/help_page2"
android:icon="#drawable/ic_help"
android:title="Help" />
<item
android:id="#+id/settings_page2"
android:icon="#drawable/ic_settings"
android:title="Settings" />
I am using coordinator layout so i think coordinator layout is the problem or might be the fragment i used.
what should i do to remove this space (space below bottom Navigation bar that already in picture)?
You could try making the height of the Bottom Bar 100dp.
My Bottomnavigationbar has no animations when i tap items. I tried changing themes, colors etc. they still don't show up. I want the items to get bigger and show the titles. Normal bottomnavigationbar also has the same issue. Do i need to do this programmatically or is it supposed to animate the items when they are pressed?
BottomNavigation:
<?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/linearLayout4"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Main">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.fragment.app.FragmentContainerView
android:id="#+id/mainFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="#+id/btnm"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/toolbar" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/btnm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#+id/mainFragment"
app:menu="#menu/nav_menu" />
</androidx.constraintlayout.widget.ConstraintLayout>
Items:
<?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/settings"
android:title="Settings"
android:icon="#drawable/ic_settings_black_24dp" />
<item
android:id="#+id/pls"
android:icon="#drawable/ic_storage_black_24dp"
android:title="Plugins" />
<item
android:id="#+id/software"
android:icon="#drawable/ic_baseline_home_24"
android:title="Manage" />
<item
android:id="#+id/deletepls"
android:icon="#drawable/ic_delete_sweep_black_24dp"
android:title="Delete plugins" />
<item
android:id="#+id/consolepage"
android:icon="#drawable/ic_desktop_mac_black_24dp"
android:title="Console"/>
</menu>
how to add a text over the item of bottomnavigationview?
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottomNavigationView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/lightGray"
android:layoutDirection="rtl"
app:itemIconTint="#drawable/nav_color_selecton"
app:itemTextAppearanceActive="#style/bottom_navigation_textappreance"
app:itemTextAppearanceInactive="#style/bottom_navigation_textappreance"
app:itemTextColor="#drawable/nav_color_selecton"
app:menu="#menu/bottom_nav_menu"
android:elevation="0dp"
/>
in menu I add tooltipText for an item. but it doesn't show anything.
<?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/nav2"
android:icon="#drawable/ic_filter_list_green_24dp"
android:title="nav2"
/>
<item
android:id="#+id/nav1"
android:icon="#drawable/ic_baseline_more_horiz_24"
android:title="more"
android:tooltipText="123"
/>
</menu>
I want to have something like this:
picture of it
I want imitate the menu as saw in picture.
Tried by using compile 'com.github.armcha:SpaceNavigationView:1.6.0' but is old and don't wanna change all entire code of my default activity with bottom navigation view.
activity_main.xml
<?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=".activities.MainActivity">
<include
layout="#layout/content_main"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="#+id/nav_view"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
/>
<!-- app:layout_constraintTop_toBottomOf="#+id/appBarLayout"-->
<android.support.design.widget.BottomNavigationView
android:id="#+id/nav_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_marginBottom="5dp"
android:background="#drawable/rett_arr_blu"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="#menu/bottom_nav_menu"
app:labelVisibilityMode="unlabeled"
/>
</android.support.constraint.ConstraintLayout>
bottom_nav_menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/navigation_home"
android:icon="#drawable/ic_home_black_24dp"
android:iconTint="#android:color/white"
android:title="#string/title_home" />
<item
android:id="#+id/navigation_news"
android:icon="#drawable/ic_notifications_black_24dp"
android:title="#string/title_news" />
<item
android:id="#+id/navigation_mappa"
android:icon="#drawable/ic_map_black_24dp"
android:title="#string/title_mappa" />
<item
android:id="#+id/navigation_convenzioni"
android:icon="#drawable/ic_convention"
android:title="#string/title_convenzioni" />
<item
android:id="#+id/navigation_altro"
android:icon="#drawable/ic_altro"
android:iconTint="#android:color/white"
android:title="#string/title_altro" />
</menu>
Result must be as picture in this repository: armcha/Space-Navigation-View. Search by google and find it...
I am trying to get 4 items on my bottom menu, but the 4th one isn't animating, should I switch to an entirely different menu format, I thought that this menu type would support 3-5 items.
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/navigation_home"
android:icon="#mipmap/news_icon"
android:title="#string/title_news" />
<item
android:id="#+id/navigation_dashboard"
android:icon="#drawable/ic_dashboard_black_24dp"
android:title="#string/title_schedule" />
<item
android:id="#+id/navigation_notifications"
android:icon="#drawable/ic_notifications_black_24dp"
android:title="#string/title_team" />
<item
android:id="#+id/login"
android:icon="#drawable/ic_notifications_black_24dp"
android:title="#string/title_team" />
</menu>
Main Activity code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:orientation="vertical"
tools:context="com.example.tibblist.attkapp.MainActivity">
<FrameLayout
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</FrameLayout>
<android.support.design.widget.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="?android:attr/windowBackground"
app:menu="#menu/navigation" />
</LinearLayout>
I made a dumb mistake turns out I wasn't returning true for that switch statement in my onNavigationItemSelected function.