Android bottom navigation view has WHITE SPACE on the left and right - android

Previously I had 3 items in my bottom navigation view, and 3 fragments associated with them. I am adding another item to it, and now there is white space on the sides, and I don't know where its coming from.
Here's the code for the bottom menu.
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/navigation_home"
android:icon="#drawable/ic_action_home"
android:title="#string/title_home" />
<item
android:id="#+id/navigation_learn"
android:icon="#drawable/ic_action_learn"
android:title="#string/title_learn" />
<item
android:id="#+id/navigation_guided"
android:icon="#drawable/ic_action_lotus"
android:title="#string/title_guided" />
<item
android:id="#+id/navigation_profile"
android:icon="#drawable/ic_action_profile"
android:title="#string/title_profile" />
</menu>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/nav_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="?android:attr/windowBackground"
android:theme="#style/Widget.BottomNavigationView"
app:itemBackground="#color/colorBottomNavigationBackground"
app:itemIconTint="#color/bnv_tab_item_foreground"
app:itemTextColor="#color/bnv_tab_item_foreground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="#menu/bottom_nav_menu" />
Does anyone know what's causing the white space?

android:background="?android:attr/windowBackground"
to
android:background="your color"
#1F1F1F

Try it, android background and app item background
android:background="#color/colorBottomNavigationBackground"
app:itemBackground="#color/colorBottomNavigationBackground"

Related

Set a particular group item at end in Navigation Drawer menu

okay, Google Keeps-Notes and Lists App have a navigation drawer like this,
Google Keeps-Notes and Lists App Navigation Drawer(Original)
I want to do same exact as I mention in this image. I want this
'EDIT'
I want that EDIT (the TextView) at right side of navigation drawer.
I achieved this far,My Navigation Drawer
<group>
<item android:title="LABALS"
android:actionLayout="#layout/main_nav_drawer_edit">
<menu>
<item
android:id="#+id/navigation_drawer_lable"
android:title="Label 1" />
<item
android:id="#+id/navigation_drawer_create_new_label"
android:title="Create new label" />
</menu>
</item>
what should I do to achieve this, Is it possible?
Create a custom View and apply to the app:actionLayout attribute of your <item>.
<item
android:id="#+id/grp_labeled"
android:title="LABALS"
app:actionLayout="#layout/main_nav_drawer_edit">
<menu>
<item
android:id="#+id/navigation_drawer_lable"
android:title="Label 1" />
<item
android:id="#+id/navigation_drawer_create_new_label"
android:title="Create new label" />
</menu>
</item>
layout:
<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">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="EDIT"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
like this?

android-how to partially tint icons of bottomNavigationView?

I'm using a viewPager with a bottomnavigationview in my android app. how can I partially tint the icons of bottomnavigationview as the user swipes the ViewPager? Chrome has such UI for example:
Use SegmentButton Library to do partially icon tint color change with smooth animation while tab changing
https://github.com/ceryle/SegmentedButton
Library allow customization as you required
add following attribute to BottomNavigationView
app:itemIconTint="#color/bnv_item_selector"
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/navigationView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
app:itemBackground="#color/white"
app:itemIconTint="#color/bnv_item_selector"
app:itemTextAppearanceActive="#style/BottomNavigationView.Active"
app:itemTextAppearanceInactive="#style/BottomNavigationView"
app:itemTextColor="#color/bottom_menu_text_selector"
app:labelVisibilityMode="labeled"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="#menu/bottom_navigation" />
bnv_item_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:color="#6CBF51" />
<item android:color="#E4E5ED" />
</selector>
Hope this will help!!

Android Bottom navigation with menu item

I have the menu item that consists of 5 items which are Home, Property, Help, Users & Account. My question is, how should I do to make the Help menu looks like the picture below. Can someone help me?
Here is my xml code for menu
<?xml version="1.0" encoding="utf-8"?>
<item
android:id="#+id/nav_home"
android:icon="#drawable/bottom_menu_home_s"
android:title="Home" />
<item
android:id="#+id/nav_property"
android:icon="#drawable/bottom_menu_property_s"
android:title="Property" />
<item
android:id="#+id/nav_panic"
android:icon="#drawable/bottom_menu_panic"
android:title="Help" />
<item
android:id="#+id/nav_user"
android:icon="#drawable/bottom_menu_users_s"
android:title="Users" />
<item
android:id="#+id/nav_account"
android:icon="#drawable/bottom_menu_accounts_s"
android:title="Account" />
Try this, as you can not do directly
<com.google.android.material.bottomnavigation.BottomNavigationView
android:layout_width="match_parent"
app:itemIconTint="#color/colorPrimary"
app:itemTextColor="#android:color/black"
app:menu="#menu/bottom_navigation"
android:clipChildren="false"
android:layout_height="56dp">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/help_button"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_gravity="center"
android:layout_marginBottom="8dp"
app:elevation="6dp"
android:scaleType="center"/>
</com.google.android.material.bottomnavigation.BottomNavigationView>
You have to download/create customized icon first. Menu doesn't allow customization like a drawable.

How to customize Bottom Navigation View?

I'm using Bottom Navigation View in my application. Everything is working fine but I need to add selected purple line when one of the items is selected. How can I achieve this?
It's Easy,
Create a color folder in resource and paste the below xml
nav_item_color_state.xml (I am using blue color, modify as per your own)
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="#FF0096D6" android:state_checked="true" />
<item android:color="#FF666666" />
</selector>
and then "itemIconTint" and "itemTextColor"
<android.support.design.widget.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="#fff"
app:itemIconTint="#color/nav_item_color_state"
app:itemTextColor="#color/nav_item_color_state"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="#menu/navigation" />

BottomNavigationView not show icon

I set an icon for BottomNavigationView but it not show .
My code:
<android.support.design.widget.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="?android:attr/windowBackground"
app:menu="#menu/navigation" />
Menu :
<item
android:id="#+id/navigation_home"
android:icon="#drawable/ic_tab_bhxh"
android:title="#string/main_tab_social_bhxh"
app:showAsAction="ifRoom" />
<item
android:id="#+id/navigation_dashboard"
android:icon="#drawable/ic_tab_bhxh"
android:title="#string/main_tab_social_bhyt"
app:showAsAction="ifRoom" />
<item
android:id="#+id/navigation_notifications"
android:icon="#drawable/ic_tab_bhxh"
android:title="#string/main_tab_social_news"
app:showAsAction="ifRoom" />
and my program :
If you have any suggest , please tell my know .
After tried some image with different background , I resolved my issue with icon background color is white .

Categories

Resources