Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android BottomNavigationView items showing without text also layout does not hiding on scroll [duplicate]

Hello Guys I have implemented design library BottomNavigationView. Its works perfectly but I don't know why my menu icon are not showing with text also I want it to hide with scroll down such as Floating Action Button. But I didn't find any way to do that. I read Developers Docs but i did not find any solution for my problem.

Here is my output- Item Showing only text which is not enabled

Expected Output- Every item should be with image and text

Here is my xml code

<android.support.design.widget.BottomNavigationView
                android:id="@+id/bottom_navigation"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:itemBackground="@android:color/white"
                app:itemIconTint="@drawable/nav_color_state_list"
                app:itemTextColor="@drawable/nav_color_state_list"
                android:layout_alignParentBottom="true"
                app:menu="@menu/bottom_navigation_menu" />

nav_color_state_list.xml drawable Code

<?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="@color/textColorSecondary" android:state_checked="false" />
</selector>

bottom_navigation_menu.xml

<?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/menu_home"
        android:title="Home"
        android:icon="@drawable/home_black_36dp"
        app:showAsAction="ifRoom|withText"/>
    <item
        android:id="@+id/menu_notification"
        android:title="Notifications"
        android:icon="@drawable/add_alert_black_36dp"
        app:showAsAction="ifRoom|withText"/>
    <item
        android:id="@+id/menu_call"
        android:title="Call"
        android:icon="@drawable/comment_black_36dp"
        app:showAsAction="ifRoom|withText"/>

    <item
        android:id="@+id/menu_more"
        android:title="More"
        android:icon="@drawable/more_horiz_black_36dp"
        app:showAsAction="ifRoom|withText"/>>
   </menu>
like image 202
Abhishek Singh Avatar asked Feb 15 '17 10:02

Abhishek Singh


1 Answers

I use this library, it's an excellent extension!

https://github.com/ittianyu/BottomNavigationViewEx

BottomNavigationViewEx bnve = (BottomNavigationViewEx) findViewById(R.id.bnve);

bnve.enableAnimation(false);

bnve.enableShiftingMode(false);

bnve.enableItemShiftingMode(false);

bnve.setIconSize(widthDp, heightDp);

bnve.setTextSize(sp);

like image 75
Amos Avatar answered Oct 23 '22 00:10

Amos