First item in bottom navigation bar is not visible, although its clickable and working properly.
Tried the solutions given to this question: KOTLIN - First item in BottomNavigationBar isn't visible, title issues
But nothing seems to work out.
<RelativeLayout 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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MapsActivity">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:itemBackground="#color/white"
app:itemIconTint="#drawable/selector"
app:itemTextColor="#drawable/selector"
app:labelVisibilityMode="labeled"
app:menu="#menu/nav_menu" />
This is the code in my xml file regarding the bottom navigation bar.
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:title="Information"
android:id="#+id/information_nav_bar"
android:icon="#drawable/ic_info" />
<item android:title="Table"
android:id="#+id/table_nav_bar"
android:icon="#drawable/ic_info" />
This is my navigation menu xml.
Related
I'm creating an Android app with a BottomNavigationView and for some reason there is blank space on either side so it doesn't fill the whole width of the screen. It's not padding, because I removed the padding and I can see the shadow of the bottom view separating the blank area from the space above. Why are my four menu items not filling the entire width of the screen?
It looks good when I have three or five items so is this just a limitation of dividing the screen space into even numbers?
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="?android:attr/windowBackground"
app:itemBackground="#color/colorPrimary"
app:itemIconTint="#color/colorNavTint"
app:itemTextColor="#color/colorNavText"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="#menu/navigation" />
navigation Menu:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/navigation_discover"
android:icon="#drawable/ic_discover"
android:title="Discover"/>
<item
android:id="#+id/navigation_search"
android:icon="#drawable/ic_search"
android:title="Search"/>
<item
android:id="#+id/navigation_messages"
android:icon="#drawable/ic_messages"
android:title="Messages"/>
<item
android:id="#+id/navigation_orders"
android:icon="#drawable/ic_orders"
android:title="Orders"/>
</menu>
and the parent ConstraintLayout:
<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">
So, I made a memo Android app, and I've used the new material BottomAppBar with a FAB, and I want to show a bottom navigation drawer when I press on the hamburger item (R.id.home) on my BottomAppBar, but I all what I've found on the Internet was regular Navigation drawers (that expand from the side).
Also, the BottomAppBar allows me to choose only a still icon for the navigation icon using app:navigationIcon attribute, while I want to have the same animated hamburger icon that converts to an arrow.
Here's my main activity_main.xml:
<?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=".MainActivity">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<ListView
android:id="#+id/noteList"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listitem="#layout/note_view" />
</androidx.core.widget.NestedScrollView>
<com.google.android.material.bottomappbar.BottomAppBar
android:id="#+id/bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:backgroundTint="#color/colorPrimary"
app:fabAlignmentMode="center"
app:fabAnimationMode="slide"
app:fabCradleRoundedCornerRadius="40dp"
app:hideOnScroll="true"
app:navigationIcon="#drawable/ic_menu_24dp" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_create_24dp"
app:backgroundTint="#color/colorAccent"
app:layout_anchor="#id/bar"
app:rippleColor="#color/rippleColor" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Note: I'm trying to make an app like Reply (a Material design study) that's available on material.io.
How can i display icons along with text in Bottom navigation of Android.
Many thanks!
click here to view the image
That looks like a CardView wrapping a BottomNavigationView.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="24dp"
android:layout_gravity="bottom"
android:layout_margin="16dp">
<android.support.design.widget.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:menu="#menu/menu_main"/>
</android.support.v7.widget.CardView>
</FrameLayout>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/lorem"
android:icon="#drawable/ic_archive"
android:title="Lorem"/>
<item
android:id="#+id/ipsum"
android:icon="#drawable/ic_archive"
android:title="Ipsum"/>
<item
android:id="#+id/dolor"
android:icon="#drawable/ic_archive"
android:title="Dolor"/>
</menu>
You can replace icon from menu with your own png Icons heaving text. And will leave title remain empty. Its tested Technique!
Completely new user of Android Studio is here, and I'm trying to make a movie review application as a school project.
So the problem here is that there will be several icons on my homepage's navigation bar, but the first icon for some reason is always blue and larger than the other icons, and I have no idea how to fix that, as you can see in the picture. Picture
Here's the XML of my homepage.xml and the nav_items.xml
HOMEPAGE
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:background="#FFFFFF"
tools:context=".Homepage">
<android.support.design.widget.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="68dp"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
app:menu="#menu/nav_items"></android.support.design.widget.BottomNavigationView>
</RelativeLayout>
Nav_items.XML
<?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:icon="#drawable/ic_input_black_24dp"
android:title="#string/nav_list" />
<item
android:icon="#drawable/outline_home_black_24"
android:title="#string/nav_home" />
</menu>
If it is blue by default then it means it is selected.
I used
setTheme(R.style.Theme_AppCompat);
to set my app theme darker.
Now I run into that issue that the selected item in my navigationbar is relativly dark, so that users can hardly see it.
Is there anything that I can use in my style to get the selected navigation item in another color?
Here is a picture of it
Here is my activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
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:visibility="visible"
tools:context="at.mrminemeet.asciimoji.MainActivity">
.....
<android.support.design.widget.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="#menu/navigation"/>
</android.support.constraint.ConstraintLayout>
Add the following to your BottomNavigationView:
app:itemIconTint="#drawable/bottom_navigation_selector"
app:itemTextColor="#drawable/bottom_navigation_selector"
In your drawable folder, create a file bottom_navigation_selector.xml and add this to it:
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns :android="http://schemas.android.com/apk/res/android">
<item android:color="#color/colorAccent" android:state_checked="true"/>
<item android:color="#android:color/darker_gray" android:state_checked="false"/>
</selector>
Finally in every activity where you use this navigation bar add this line to onCreate() and onResume()
bottomNavigationView.setSelectedItemId(R.id.item);
You can specify the BottomNavigationView_itemBackground attribute to your BottomNavigationView, you can set a selector as a background with different colors for the normal and selected states