Item showing only on click on BottomNavigationView



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















So I want a navigation bar at the bottom of the screen with 4 items but for some reason only the first one is showing and the others appear only when i click them.



<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@color/white"
app:itemTextColor="@color/black"
app:menu="@menu/navigation_bar_bottom_menu" />


My menu:



<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/nav_home"
android:title="@string/navigation_bar_home_text" />

<item
android:id="@+id/nav_inbox"
android:title="@string/navigation_bar_inbox_text" />

<item
android:id="@+id/nav_notes"
android:title="@string/navigation_bar_notes_text" />

<item
android:id="@+id/nav_profile"
android:title="@string/navigation_bar_profile_text" />

</menu>


The bar is displayed like this just with the first item showing:



enter image description here










share|improve this question






















  • I think you can set visibility:gone and on click change it to visibility:visibile

    – amir133
    Nov 15 '18 at 8:01


















1















So I want a navigation bar at the bottom of the screen with 4 items but for some reason only the first one is showing and the others appear only when i click them.



<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@color/white"
app:itemTextColor="@color/black"
app:menu="@menu/navigation_bar_bottom_menu" />


My menu:



<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/nav_home"
android:title="@string/navigation_bar_home_text" />

<item
android:id="@+id/nav_inbox"
android:title="@string/navigation_bar_inbox_text" />

<item
android:id="@+id/nav_notes"
android:title="@string/navigation_bar_notes_text" />

<item
android:id="@+id/nav_profile"
android:title="@string/navigation_bar_profile_text" />

</menu>


The bar is displayed like this just with the first item showing:



enter image description here










share|improve this question






















  • I think you can set visibility:gone and on click change it to visibility:visibile

    – amir133
    Nov 15 '18 at 8:01














1












1








1








So I want a navigation bar at the bottom of the screen with 4 items but for some reason only the first one is showing and the others appear only when i click them.



<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@color/white"
app:itemTextColor="@color/black"
app:menu="@menu/navigation_bar_bottom_menu" />


My menu:



<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/nav_home"
android:title="@string/navigation_bar_home_text" />

<item
android:id="@+id/nav_inbox"
android:title="@string/navigation_bar_inbox_text" />

<item
android:id="@+id/nav_notes"
android:title="@string/navigation_bar_notes_text" />

<item
android:id="@+id/nav_profile"
android:title="@string/navigation_bar_profile_text" />

</menu>


The bar is displayed like this just with the first item showing:



enter image description here










share|improve this question














So I want a navigation bar at the bottom of the screen with 4 items but for some reason only the first one is showing and the others appear only when i click them.



<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@color/white"
app:itemTextColor="@color/black"
app:menu="@menu/navigation_bar_bottom_menu" />


My menu:



<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/nav_home"
android:title="@string/navigation_bar_home_text" />

<item
android:id="@+id/nav_inbox"
android:title="@string/navigation_bar_inbox_text" />

<item
android:id="@+id/nav_notes"
android:title="@string/navigation_bar_notes_text" />

<item
android:id="@+id/nav_profile"
android:title="@string/navigation_bar_profile_text" />

</menu>


The bar is displayed like this just with the first item showing:



enter image description here







android bottomnavigationview






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 '18 at 7:57









anMCanMC

306




306












  • I think you can set visibility:gone and on click change it to visibility:visibile

    – amir133
    Nov 15 '18 at 8:01


















  • I think you can set visibility:gone and on click change it to visibility:visibile

    – amir133
    Nov 15 '18 at 8:01

















I think you can set visibility:gone and on click change it to visibility:visibile

– amir133
Nov 15 '18 at 8:01






I think you can set visibility:gone and on click change it to visibility:visibile

– amir133
Nov 15 '18 at 8:01













2 Answers
2






active

oldest

votes


















0














 <android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:background="@color/gray_background"
app:itemIconTint="@color/nav_item_state_list"
app:itemTextColor="@color/nav_item_state_list"
app:labelVisibilityMode="labeled"
android:theme="@style/Widget.BottomNavigationView"
app:menu="@menu/bottom_navigation_items"/>



<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/colorPrimaryLite"
android:state_pressed="true"/>
<item android:color="@color/colorPrimaryLite"
android:state_checked="true"/>
<item android:color="@color/grayDark"
android:state_checked="false"/>
<item android:color="@color/white"/>
</selector>





share|improve this answer























  • After adding app:labelVisibilityMode="labeled" it worked. Thank you so much.

    – anMC
    Nov 15 '18 at 9:45


















0














Here is the example



Create a color file
navigation_item_text_color.xml



<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:color="@color/black" />
<item android:color="@android:color/darker_gray" />
</selector>


then put to color folder (if you don't have color folder -> just create it manually)



Then



<com.google.android.material.bottomnavigation.BottomNavigationView
...
app:itemTextColor="@color/navigation_item_text_color" />


More



If you bottom menu item have icon, you can change icon color like
app:itemIconTint="@color/navigation_item_text_color"






share|improve this answer























  • I've tried it but for some reason it still doesn't work :(

    – anMC
    Nov 15 '18 at 8:54











  • I have a small demo here, you can check it github.com/PhanVanLinh/AndroidBottomNavigationView

    – Phan Van Linh
    Nov 15 '18 at 9:04











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53314754%2fitem-showing-only-on-click-on-bottomnavigationview%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














 <android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:background="@color/gray_background"
app:itemIconTint="@color/nav_item_state_list"
app:itemTextColor="@color/nav_item_state_list"
app:labelVisibilityMode="labeled"
android:theme="@style/Widget.BottomNavigationView"
app:menu="@menu/bottom_navigation_items"/>



<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/colorPrimaryLite"
android:state_pressed="true"/>
<item android:color="@color/colorPrimaryLite"
android:state_checked="true"/>
<item android:color="@color/grayDark"
android:state_checked="false"/>
<item android:color="@color/white"/>
</selector>





share|improve this answer























  • After adding app:labelVisibilityMode="labeled" it worked. Thank you so much.

    – anMC
    Nov 15 '18 at 9:45















0














 <android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:background="@color/gray_background"
app:itemIconTint="@color/nav_item_state_list"
app:itemTextColor="@color/nav_item_state_list"
app:labelVisibilityMode="labeled"
android:theme="@style/Widget.BottomNavigationView"
app:menu="@menu/bottom_navigation_items"/>



<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/colorPrimaryLite"
android:state_pressed="true"/>
<item android:color="@color/colorPrimaryLite"
android:state_checked="true"/>
<item android:color="@color/grayDark"
android:state_checked="false"/>
<item android:color="@color/white"/>
</selector>





share|improve this answer























  • After adding app:labelVisibilityMode="labeled" it worked. Thank you so much.

    – anMC
    Nov 15 '18 at 9:45













0












0








0







 <android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:background="@color/gray_background"
app:itemIconTint="@color/nav_item_state_list"
app:itemTextColor="@color/nav_item_state_list"
app:labelVisibilityMode="labeled"
android:theme="@style/Widget.BottomNavigationView"
app:menu="@menu/bottom_navigation_items"/>



<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/colorPrimaryLite"
android:state_pressed="true"/>
<item android:color="@color/colorPrimaryLite"
android:state_checked="true"/>
<item android:color="@color/grayDark"
android:state_checked="false"/>
<item android:color="@color/white"/>
</selector>





share|improve this answer













 <android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:background="@color/gray_background"
app:itemIconTint="@color/nav_item_state_list"
app:itemTextColor="@color/nav_item_state_list"
app:labelVisibilityMode="labeled"
android:theme="@style/Widget.BottomNavigationView"
app:menu="@menu/bottom_navigation_items"/>



<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/colorPrimaryLite"
android:state_pressed="true"/>
<item android:color="@color/colorPrimaryLite"
android:state_checked="true"/>
<item android:color="@color/grayDark"
android:state_checked="false"/>
<item android:color="@color/white"/>
</selector>






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 15 '18 at 9:20









veerendranveerendran

364




364












  • After adding app:labelVisibilityMode="labeled" it worked. Thank you so much.

    – anMC
    Nov 15 '18 at 9:45

















  • After adding app:labelVisibilityMode="labeled" it worked. Thank you so much.

    – anMC
    Nov 15 '18 at 9:45
















After adding app:labelVisibilityMode="labeled" it worked. Thank you so much.

– anMC
Nov 15 '18 at 9:45





After adding app:labelVisibilityMode="labeled" it worked. Thank you so much.

– anMC
Nov 15 '18 at 9:45













0














Here is the example



Create a color file
navigation_item_text_color.xml



<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:color="@color/black" />
<item android:color="@android:color/darker_gray" />
</selector>


then put to color folder (if you don't have color folder -> just create it manually)



Then



<com.google.android.material.bottomnavigation.BottomNavigationView
...
app:itemTextColor="@color/navigation_item_text_color" />


More



If you bottom menu item have icon, you can change icon color like
app:itemIconTint="@color/navigation_item_text_color"






share|improve this answer























  • I've tried it but for some reason it still doesn't work :(

    – anMC
    Nov 15 '18 at 8:54











  • I have a small demo here, you can check it github.com/PhanVanLinh/AndroidBottomNavigationView

    – Phan Van Linh
    Nov 15 '18 at 9:04















0














Here is the example



Create a color file
navigation_item_text_color.xml



<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:color="@color/black" />
<item android:color="@android:color/darker_gray" />
</selector>


then put to color folder (if you don't have color folder -> just create it manually)



Then



<com.google.android.material.bottomnavigation.BottomNavigationView
...
app:itemTextColor="@color/navigation_item_text_color" />


More



If you bottom menu item have icon, you can change icon color like
app:itemIconTint="@color/navigation_item_text_color"






share|improve this answer























  • I've tried it but for some reason it still doesn't work :(

    – anMC
    Nov 15 '18 at 8:54











  • I have a small demo here, you can check it github.com/PhanVanLinh/AndroidBottomNavigationView

    – Phan Van Linh
    Nov 15 '18 at 9:04













0












0








0







Here is the example



Create a color file
navigation_item_text_color.xml



<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:color="@color/black" />
<item android:color="@android:color/darker_gray" />
</selector>


then put to color folder (if you don't have color folder -> just create it manually)



Then



<com.google.android.material.bottomnavigation.BottomNavigationView
...
app:itemTextColor="@color/navigation_item_text_color" />


More



If you bottom menu item have icon, you can change icon color like
app:itemIconTint="@color/navigation_item_text_color"






share|improve this answer













Here is the example



Create a color file
navigation_item_text_color.xml



<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:color="@color/black" />
<item android:color="@android:color/darker_gray" />
</selector>


then put to color folder (if you don't have color folder -> just create it manually)



Then



<com.google.android.material.bottomnavigation.BottomNavigationView
...
app:itemTextColor="@color/navigation_item_text_color" />


More



If you bottom menu item have icon, you can change icon color like
app:itemIconTint="@color/navigation_item_text_color"







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 15 '18 at 8:06









Phan Van LinhPhan Van Linh

22.4k12118147




22.4k12118147












  • I've tried it but for some reason it still doesn't work :(

    – anMC
    Nov 15 '18 at 8:54











  • I have a small demo here, you can check it github.com/PhanVanLinh/AndroidBottomNavigationView

    – Phan Van Linh
    Nov 15 '18 at 9:04

















  • I've tried it but for some reason it still doesn't work :(

    – anMC
    Nov 15 '18 at 8:54











  • I have a small demo here, you can check it github.com/PhanVanLinh/AndroidBottomNavigationView

    – Phan Van Linh
    Nov 15 '18 at 9:04
















I've tried it but for some reason it still doesn't work :(

– anMC
Nov 15 '18 at 8:54





I've tried it but for some reason it still doesn't work :(

– anMC
Nov 15 '18 at 8:54













I have a small demo here, you can check it github.com/PhanVanLinh/AndroidBottomNavigationView

– Phan Van Linh
Nov 15 '18 at 9:04





I have a small demo here, you can check it github.com/PhanVanLinh/AndroidBottomNavigationView

– Phan Van Linh
Nov 15 '18 at 9:04

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53314754%2fitem-showing-only-on-click-on-bottomnavigationview%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

Syphilis

Darth Vader #20