android.support.design.widget.BottomNavigationView how can I change the icon of unselected items instead of just the tint colourIncomplete android appcompat fragmentsupport: missing resource divider_horizontal_bright_opaque.9.pngI get error when use android:background and item_bg.xmlGetting Error inflating class android.support.design.widget.NavigationViewandroid.view.InflateException: Binary XML file line #7: Error inflating class Button at android.view.LayoutInflater.createViewFromTagDrawable not working on API 19How to change a tabLayout clickable background color?Resources$NotFoundException Android 4.4my app stops working when i try to start on android studioError inflating class <unknown> Caused by InvocationTargetExceptionError inflating class <unknown> Caused by ViewPagerAdapter instantiateItem

How could Tony Stark make this in Endgame?

Pre-plastic human skin alternative

"Whatever a Russian does, they end up making the Kalashnikov gun"? Are there any similar proverbs in English?

Philosophical question on logistic regression: why isn't the optimal threshold value trained?

How to display Aura JS Errors Lightning Out

What happened to Captain America in Endgame?

Function pointer with named arguments?

Two field separators (colon and space) in awk

Does tea made with boiling water cool faster than tea made with boiled (but still hot) water?

What happens to Mjolnir (Thor's hammer) at the end of Endgame?

How to stop co-workers from teasing me because I know Russian?

Can we say “you can pay when the order gets ready”?

Could the terminal length of components like resistors be reduced?

Why do games have consumables?

Alignment of various blocks in tikz

A strange hotel

How do I check if a string is entirely made of the same substring?

How do I reattach a shelf to the wall when it ripped out of the wall?

Do I have an "anti-research" personality?

A ​Note ​on ​N!

How to limit Drive Letters Windows assigns to new removable USB drives

Aliens crash on Earth and go into stasis to wait for technology to fix their ship

How do I deal with a coworker that keeps asking to make small superficial changes to a report, and it is seriously triggering my anxiety?

How did Captain America manage to do this?



android.support.design.widget.BottomNavigationView how can I change the icon of unselected items instead of just the tint colour


Incomplete android appcompat fragmentsupport: missing resource divider_horizontal_bright_opaque.9.pngI get error when use android:background and item_bg.xmlGetting Error inflating class android.support.design.widget.NavigationViewandroid.view.InflateException: Binary XML file line #7: Error inflating class Button at android.view.LayoutInflater.createViewFromTagDrawable not working on API 19How to change a tabLayout clickable background color?Resources$NotFoundException Android 4.4my app stops working when i try to start on android studioError inflating class <unknown> Caused by InvocationTargetExceptionError inflating class <unknown> Caused by ViewPagerAdapter instantiateItem






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








0















First of all, if its duplicated please let me know because I cannot find it.



I m working with the BottomNavigationView with custom icons.



My problem is that, after selecting an item, when its unselected the icon changes its colour/tint rather than reverting to its initial state.



The problem is happening only with the message tab.



This is the initial state (speech bubble is border only)



Initial stage



This is when its highlighted



Highlighted stage



This is the wrong one (speech bubble is now solid white but it should have a border only)



Wrong sate



I try to access that views in the OnNavigationItemSelectedListener but I couldn't...any help will be a life saver ;)



This is the method



private val onNavigationItemSelected = BottomNavigationView.OnNavigationItemSelectedListener 

var result = false
when (it.itemId)
R.id.bottombarWalks ->
it.icon = ResourcesCompat.getDrawable(resources, R.drawable.walks_on,null)
switchFragment(0, WalksFragment())
result = true

R.id.bottombarMembership ->
it.icon = ResourcesCompat.getDrawable(resources, R.drawable.membership_on,null)
switchFragment(1, TabFragment.newInstance("Membership tab"))
result = true

R.id.bottombarHome ->
it.icon = ResourcesCompat.getDrawable(resources, R.drawable.home_on,null)
switchFragment(2, HomeFragment())
result = true

R.id.bottombarMessages ->
it.icon = ResourcesCompat.getDrawable(resources, R.drawable.messages_on,null)
switchFragment(3, MessagesTabFragment())
result = true

R.id.bottombarMore ->
it.icon = ResourcesCompat.getDrawable(resources, R.drawable.more_on,null)
switchFragment(4, MoreFragment())
result = true


result



Thanks in advance



@FrancislainyCampos solution



This is the XML that define the bottomNavBar Tabs after applying the @FrancislainyCampos suggestion



bottomBar_menu



This is the selector that I added



tab_selector



With that solution the app is crashing trying to inflate the BottomNavBar with this log:



java.lang.RuntimeException: Unable to start activity ComponentInfouk.org.ramblers.walkreg/uk.org.ramblers.walkreg.ui.MainActivity: android.view.InflateException: Binary XML file line #22: Binary XML file line #22: Error inflating class android.support.design.widget.BottomNavigationView
[...]
Caused by: android.view.InflateException: Binary XML file line #22: Binary XML file line #22: Error inflating class android.support.design.widget.BottomNavigationView
Caused by: android.view.InflateException: Binary XML file line #22: Error inflating class android.support.design.widget.BottomNavigationView
Caused by: java.lang.reflect.InvocationTargetException
[...]
Caused by: android.content.res.Resources$NotFoundException: Drawable uk.org.ramblers.walkreg:drawable/tab_selector with resource ID #0x7f0700ce
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/tab_selector.xml from drawable resource ID #0x7f0700ce



Did someone have another idea...I m happy to try whatever because I m out of ideas










share|improve this question
























  • Hi, do you have a XML file where you set the drawables for the selected and unselected states using selectors? That's usually how I control which icons to show for each scenario.

    – Francislainy Campos
    Mar 22 at 19:50











  • @FrancislainyCampos it didn't work. I added the selector I create in the question and updated the XML in the case is something wrong that I missed...thanks anyway!!!

    – Carlos Cabello Ruiz
    Mar 25 at 12:04











  • what is drawable tab_selector.xml?

    – Karan Mer
    Mar 25 at 12:15











  • Do you have all your drawables inside res/drawable folder or did you create folders like drawable-v21?

    – forpas
    Mar 25 at 13:46











  • Thanks @forpas all of them are into the drawable folder...to be precise they are in the drawable-nodpi folder

    – Carlos Cabello Ruiz
    Mar 25 at 15:14


















0















First of all, if its duplicated please let me know because I cannot find it.



I m working with the BottomNavigationView with custom icons.



My problem is that, after selecting an item, when its unselected the icon changes its colour/tint rather than reverting to its initial state.



The problem is happening only with the message tab.



This is the initial state (speech bubble is border only)



Initial stage



This is when its highlighted



Highlighted stage



This is the wrong one (speech bubble is now solid white but it should have a border only)



Wrong sate



I try to access that views in the OnNavigationItemSelectedListener but I couldn't...any help will be a life saver ;)



This is the method



private val onNavigationItemSelected = BottomNavigationView.OnNavigationItemSelectedListener 

var result = false
when (it.itemId)
R.id.bottombarWalks ->
it.icon = ResourcesCompat.getDrawable(resources, R.drawable.walks_on,null)
switchFragment(0, WalksFragment())
result = true

R.id.bottombarMembership ->
it.icon = ResourcesCompat.getDrawable(resources, R.drawable.membership_on,null)
switchFragment(1, TabFragment.newInstance("Membership tab"))
result = true

R.id.bottombarHome ->
it.icon = ResourcesCompat.getDrawable(resources, R.drawable.home_on,null)
switchFragment(2, HomeFragment())
result = true

R.id.bottombarMessages ->
it.icon = ResourcesCompat.getDrawable(resources, R.drawable.messages_on,null)
switchFragment(3, MessagesTabFragment())
result = true

R.id.bottombarMore ->
it.icon = ResourcesCompat.getDrawable(resources, R.drawable.more_on,null)
switchFragment(4, MoreFragment())
result = true


result



Thanks in advance



@FrancislainyCampos solution



This is the XML that define the bottomNavBar Tabs after applying the @FrancislainyCampos suggestion



bottomBar_menu



This is the selector that I added



tab_selector



With that solution the app is crashing trying to inflate the BottomNavBar with this log:



java.lang.RuntimeException: Unable to start activity ComponentInfouk.org.ramblers.walkreg/uk.org.ramblers.walkreg.ui.MainActivity: android.view.InflateException: Binary XML file line #22: Binary XML file line #22: Error inflating class android.support.design.widget.BottomNavigationView
[...]
Caused by: android.view.InflateException: Binary XML file line #22: Binary XML file line #22: Error inflating class android.support.design.widget.BottomNavigationView
Caused by: android.view.InflateException: Binary XML file line #22: Error inflating class android.support.design.widget.BottomNavigationView
Caused by: java.lang.reflect.InvocationTargetException
[...]
Caused by: android.content.res.Resources$NotFoundException: Drawable uk.org.ramblers.walkreg:drawable/tab_selector with resource ID #0x7f0700ce
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/tab_selector.xml from drawable resource ID #0x7f0700ce



Did someone have another idea...I m happy to try whatever because I m out of ideas










share|improve this question
























  • Hi, do you have a XML file where you set the drawables for the selected and unselected states using selectors? That's usually how I control which icons to show for each scenario.

    – Francislainy Campos
    Mar 22 at 19:50











  • @FrancislainyCampos it didn't work. I added the selector I create in the question and updated the XML in the case is something wrong that I missed...thanks anyway!!!

    – Carlos Cabello Ruiz
    Mar 25 at 12:04











  • what is drawable tab_selector.xml?

    – Karan Mer
    Mar 25 at 12:15











  • Do you have all your drawables inside res/drawable folder or did you create folders like drawable-v21?

    – forpas
    Mar 25 at 13:46











  • Thanks @forpas all of them are into the drawable folder...to be precise they are in the drawable-nodpi folder

    – Carlos Cabello Ruiz
    Mar 25 at 15:14














0












0








0








First of all, if its duplicated please let me know because I cannot find it.



I m working with the BottomNavigationView with custom icons.



My problem is that, after selecting an item, when its unselected the icon changes its colour/tint rather than reverting to its initial state.



The problem is happening only with the message tab.



This is the initial state (speech bubble is border only)



Initial stage



This is when its highlighted



Highlighted stage



This is the wrong one (speech bubble is now solid white but it should have a border only)



Wrong sate



I try to access that views in the OnNavigationItemSelectedListener but I couldn't...any help will be a life saver ;)



This is the method



private val onNavigationItemSelected = BottomNavigationView.OnNavigationItemSelectedListener 

var result = false
when (it.itemId)
R.id.bottombarWalks ->
it.icon = ResourcesCompat.getDrawable(resources, R.drawable.walks_on,null)
switchFragment(0, WalksFragment())
result = true

R.id.bottombarMembership ->
it.icon = ResourcesCompat.getDrawable(resources, R.drawable.membership_on,null)
switchFragment(1, TabFragment.newInstance("Membership tab"))
result = true

R.id.bottombarHome ->
it.icon = ResourcesCompat.getDrawable(resources, R.drawable.home_on,null)
switchFragment(2, HomeFragment())
result = true

R.id.bottombarMessages ->
it.icon = ResourcesCompat.getDrawable(resources, R.drawable.messages_on,null)
switchFragment(3, MessagesTabFragment())
result = true

R.id.bottombarMore ->
it.icon = ResourcesCompat.getDrawable(resources, R.drawable.more_on,null)
switchFragment(4, MoreFragment())
result = true


result



Thanks in advance



@FrancislainyCampos solution



This is the XML that define the bottomNavBar Tabs after applying the @FrancislainyCampos suggestion



bottomBar_menu



This is the selector that I added



tab_selector



With that solution the app is crashing trying to inflate the BottomNavBar with this log:



java.lang.RuntimeException: Unable to start activity ComponentInfouk.org.ramblers.walkreg/uk.org.ramblers.walkreg.ui.MainActivity: android.view.InflateException: Binary XML file line #22: Binary XML file line #22: Error inflating class android.support.design.widget.BottomNavigationView
[...]
Caused by: android.view.InflateException: Binary XML file line #22: Binary XML file line #22: Error inflating class android.support.design.widget.BottomNavigationView
Caused by: android.view.InflateException: Binary XML file line #22: Error inflating class android.support.design.widget.BottomNavigationView
Caused by: java.lang.reflect.InvocationTargetException
[...]
Caused by: android.content.res.Resources$NotFoundException: Drawable uk.org.ramblers.walkreg:drawable/tab_selector with resource ID #0x7f0700ce
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/tab_selector.xml from drawable resource ID #0x7f0700ce



Did someone have another idea...I m happy to try whatever because I m out of ideas










share|improve this question
















First of all, if its duplicated please let me know because I cannot find it.



I m working with the BottomNavigationView with custom icons.



My problem is that, after selecting an item, when its unselected the icon changes its colour/tint rather than reverting to its initial state.



The problem is happening only with the message tab.



This is the initial state (speech bubble is border only)



Initial stage



This is when its highlighted



Highlighted stage



This is the wrong one (speech bubble is now solid white but it should have a border only)



Wrong sate



I try to access that views in the OnNavigationItemSelectedListener but I couldn't...any help will be a life saver ;)



This is the method



private val onNavigationItemSelected = BottomNavigationView.OnNavigationItemSelectedListener 

var result = false
when (it.itemId)
R.id.bottombarWalks ->
it.icon = ResourcesCompat.getDrawable(resources, R.drawable.walks_on,null)
switchFragment(0, WalksFragment())
result = true

R.id.bottombarMembership ->
it.icon = ResourcesCompat.getDrawable(resources, R.drawable.membership_on,null)
switchFragment(1, TabFragment.newInstance("Membership tab"))
result = true

R.id.bottombarHome ->
it.icon = ResourcesCompat.getDrawable(resources, R.drawable.home_on,null)
switchFragment(2, HomeFragment())
result = true

R.id.bottombarMessages ->
it.icon = ResourcesCompat.getDrawable(resources, R.drawable.messages_on,null)
switchFragment(3, MessagesTabFragment())
result = true

R.id.bottombarMore ->
it.icon = ResourcesCompat.getDrawable(resources, R.drawable.more_on,null)
switchFragment(4, MoreFragment())
result = true


result



Thanks in advance



@FrancislainyCampos solution



This is the XML that define the bottomNavBar Tabs after applying the @FrancislainyCampos suggestion



bottomBar_menu



This is the selector that I added



tab_selector



With that solution the app is crashing trying to inflate the BottomNavBar with this log:



java.lang.RuntimeException: Unable to start activity ComponentInfouk.org.ramblers.walkreg/uk.org.ramblers.walkreg.ui.MainActivity: android.view.InflateException: Binary XML file line #22: Binary XML file line #22: Error inflating class android.support.design.widget.BottomNavigationView
[...]
Caused by: android.view.InflateException: Binary XML file line #22: Binary XML file line #22: Error inflating class android.support.design.widget.BottomNavigationView
Caused by: android.view.InflateException: Binary XML file line #22: Error inflating class android.support.design.widget.BottomNavigationView
Caused by: java.lang.reflect.InvocationTargetException
[...]
Caused by: android.content.res.Resources$NotFoundException: Drawable uk.org.ramblers.walkreg:drawable/tab_selector with resource ID #0x7f0700ce
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/tab_selector.xml from drawable resource ID #0x7f0700ce



Did someone have another idea...I m happy to try whatever because I m out of ideas







android kotlin bottomnavigationview






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 12:11







Carlos Cabello Ruiz

















asked Mar 22 at 17:37









Carlos Cabello RuizCarlos Cabello Ruiz

9819




9819












  • Hi, do you have a XML file where you set the drawables for the selected and unselected states using selectors? That's usually how I control which icons to show for each scenario.

    – Francislainy Campos
    Mar 22 at 19:50











  • @FrancislainyCampos it didn't work. I added the selector I create in the question and updated the XML in the case is something wrong that I missed...thanks anyway!!!

    – Carlos Cabello Ruiz
    Mar 25 at 12:04











  • what is drawable tab_selector.xml?

    – Karan Mer
    Mar 25 at 12:15











  • Do you have all your drawables inside res/drawable folder or did you create folders like drawable-v21?

    – forpas
    Mar 25 at 13:46











  • Thanks @forpas all of them are into the drawable folder...to be precise they are in the drawable-nodpi folder

    – Carlos Cabello Ruiz
    Mar 25 at 15:14


















  • Hi, do you have a XML file where you set the drawables for the selected and unselected states using selectors? That's usually how I control which icons to show for each scenario.

    – Francislainy Campos
    Mar 22 at 19:50











  • @FrancislainyCampos it didn't work. I added the selector I create in the question and updated the XML in the case is something wrong that I missed...thanks anyway!!!

    – Carlos Cabello Ruiz
    Mar 25 at 12:04











  • what is drawable tab_selector.xml?

    – Karan Mer
    Mar 25 at 12:15











  • Do you have all your drawables inside res/drawable folder or did you create folders like drawable-v21?

    – forpas
    Mar 25 at 13:46











  • Thanks @forpas all of them are into the drawable folder...to be precise they are in the drawable-nodpi folder

    – Carlos Cabello Ruiz
    Mar 25 at 15:14

















Hi, do you have a XML file where you set the drawables for the selected and unselected states using selectors? That's usually how I control which icons to show for each scenario.

– Francislainy Campos
Mar 22 at 19:50





Hi, do you have a XML file where you set the drawables for the selected and unselected states using selectors? That's usually how I control which icons to show for each scenario.

– Francislainy Campos
Mar 22 at 19:50













@FrancislainyCampos it didn't work. I added the selector I create in the question and updated the XML in the case is something wrong that I missed...thanks anyway!!!

– Carlos Cabello Ruiz
Mar 25 at 12:04





@FrancislainyCampos it didn't work. I added the selector I create in the question and updated the XML in the case is something wrong that I missed...thanks anyway!!!

– Carlos Cabello Ruiz
Mar 25 at 12:04













what is drawable tab_selector.xml?

– Karan Mer
Mar 25 at 12:15





what is drawable tab_selector.xml?

– Karan Mer
Mar 25 at 12:15













Do you have all your drawables inside res/drawable folder or did you create folders like drawable-v21?

– forpas
Mar 25 at 13:46





Do you have all your drawables inside res/drawable folder or did you create folders like drawable-v21?

– forpas
Mar 25 at 13:46













Thanks @forpas all of them are into the drawable folder...to be precise they are in the drawable-nodpi folder

– Carlos Cabello Ruiz
Mar 25 at 15:14






Thanks @forpas all of them are into the drawable folder...to be precise they are in the drawable-nodpi folder

– Carlos Cabello Ruiz
Mar 25 at 15:14













1 Answer
1






active

oldest

votes


















0














That's what I have on this project:



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



<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item
android:id="@+id/tab_home"
android:icon="@drawable/home_blue"
android:title="@string/tab_home"
app:showAsAction="always"/>

<item
android:id="@+id/tab_location"
android:icon="@drawable/ic_location"
android:title="Location"
app:showAsAction="always"/>

<item
android:id="@+id/tab_tic_tac_toe"
android:icon="@drawable/ic_tic_tac_toe"
android:title="Tic Tac Toe"
app:showAsAction="always"/>




 private fun bottomBarNavigationView() 

navigation.setOnNavigationItemSelectedListener(onNavigationItemSelectedListener)
navigation.selectedItemId = R.id.tab_tic_tac_toe


private val onNavigationItemSelectedListener = object : OnNavigationItemSelectedListener
override fun onNavigationItemSelected(item: MenuItem): Boolean

when (item.itemId)
R.id.tab_home ->
displayView(FRAG_COUNTER)

return true


R.id.tab_location ->
displayView(FRAG_LOCATION)

return true


R.id.tab_tic_tac_toe ->
displayView(FRAG_TIC_TAC)

return true



return false







share|improve this answer























  • Thanks for sharing but the icons that you used are just changing its colour. What I need is to change the whole icon not just the colour...the message icon tab shown on the pictures of the question when is unselected are different

    – Carlos Cabello Ruiz
    Mar 27 at 14:42












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%2f55305068%2fandroid-support-design-widget-bottomnavigationview-how-can-i-change-the-icon-of%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














That's what I have on this project:



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



<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item
android:id="@+id/tab_home"
android:icon="@drawable/home_blue"
android:title="@string/tab_home"
app:showAsAction="always"/>

<item
android:id="@+id/tab_location"
android:icon="@drawable/ic_location"
android:title="Location"
app:showAsAction="always"/>

<item
android:id="@+id/tab_tic_tac_toe"
android:icon="@drawable/ic_tic_tac_toe"
android:title="Tic Tac Toe"
app:showAsAction="always"/>




 private fun bottomBarNavigationView() 

navigation.setOnNavigationItemSelectedListener(onNavigationItemSelectedListener)
navigation.selectedItemId = R.id.tab_tic_tac_toe


private val onNavigationItemSelectedListener = object : OnNavigationItemSelectedListener
override fun onNavigationItemSelected(item: MenuItem): Boolean

when (item.itemId)
R.id.tab_home ->
displayView(FRAG_COUNTER)

return true


R.id.tab_location ->
displayView(FRAG_LOCATION)

return true


R.id.tab_tic_tac_toe ->
displayView(FRAG_TIC_TAC)

return true



return false







share|improve this answer























  • Thanks for sharing but the icons that you used are just changing its colour. What I need is to change the whole icon not just the colour...the message icon tab shown on the pictures of the question when is unselected are different

    – Carlos Cabello Ruiz
    Mar 27 at 14:42
















0














That's what I have on this project:



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



<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item
android:id="@+id/tab_home"
android:icon="@drawable/home_blue"
android:title="@string/tab_home"
app:showAsAction="always"/>

<item
android:id="@+id/tab_location"
android:icon="@drawable/ic_location"
android:title="Location"
app:showAsAction="always"/>

<item
android:id="@+id/tab_tic_tac_toe"
android:icon="@drawable/ic_tic_tac_toe"
android:title="Tic Tac Toe"
app:showAsAction="always"/>




 private fun bottomBarNavigationView() 

navigation.setOnNavigationItemSelectedListener(onNavigationItemSelectedListener)
navigation.selectedItemId = R.id.tab_tic_tac_toe


private val onNavigationItemSelectedListener = object : OnNavigationItemSelectedListener
override fun onNavigationItemSelected(item: MenuItem): Boolean

when (item.itemId)
R.id.tab_home ->
displayView(FRAG_COUNTER)

return true


R.id.tab_location ->
displayView(FRAG_LOCATION)

return true


R.id.tab_tic_tac_toe ->
displayView(FRAG_TIC_TAC)

return true



return false







share|improve this answer























  • Thanks for sharing but the icons that you used are just changing its colour. What I need is to change the whole icon not just the colour...the message icon tab shown on the pictures of the question when is unselected are different

    – Carlos Cabello Ruiz
    Mar 27 at 14:42














0












0








0







That's what I have on this project:



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



<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item
android:id="@+id/tab_home"
android:icon="@drawable/home_blue"
android:title="@string/tab_home"
app:showAsAction="always"/>

<item
android:id="@+id/tab_location"
android:icon="@drawable/ic_location"
android:title="Location"
app:showAsAction="always"/>

<item
android:id="@+id/tab_tic_tac_toe"
android:icon="@drawable/ic_tic_tac_toe"
android:title="Tic Tac Toe"
app:showAsAction="always"/>




 private fun bottomBarNavigationView() 

navigation.setOnNavigationItemSelectedListener(onNavigationItemSelectedListener)
navigation.selectedItemId = R.id.tab_tic_tac_toe


private val onNavigationItemSelectedListener = object : OnNavigationItemSelectedListener
override fun onNavigationItemSelected(item: MenuItem): Boolean

when (item.itemId)
R.id.tab_home ->
displayView(FRAG_COUNTER)

return true


R.id.tab_location ->
displayView(FRAG_LOCATION)

return true


R.id.tab_tic_tac_toe ->
displayView(FRAG_TIC_TAC)

return true



return false







share|improve this answer













That's what I have on this project:



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



<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item
android:id="@+id/tab_home"
android:icon="@drawable/home_blue"
android:title="@string/tab_home"
app:showAsAction="always"/>

<item
android:id="@+id/tab_location"
android:icon="@drawable/ic_location"
android:title="Location"
app:showAsAction="always"/>

<item
android:id="@+id/tab_tic_tac_toe"
android:icon="@drawable/ic_tic_tac_toe"
android:title="Tic Tac Toe"
app:showAsAction="always"/>




 private fun bottomBarNavigationView() 

navigation.setOnNavigationItemSelectedListener(onNavigationItemSelectedListener)
navigation.selectedItemId = R.id.tab_tic_tac_toe


private val onNavigationItemSelectedListener = object : OnNavigationItemSelectedListener
override fun onNavigationItemSelected(item: MenuItem): Boolean

when (item.itemId)
R.id.tab_home ->
displayView(FRAG_COUNTER)

return true


R.id.tab_location ->
displayView(FRAG_LOCATION)

return true


R.id.tab_tic_tac_toe ->
displayView(FRAG_TIC_TAC)

return true



return false








share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 26 at 19:50









Francislainy CamposFrancislainy Campos

226218




226218












  • Thanks for sharing but the icons that you used are just changing its colour. What I need is to change the whole icon not just the colour...the message icon tab shown on the pictures of the question when is unselected are different

    – Carlos Cabello Ruiz
    Mar 27 at 14:42


















  • Thanks for sharing but the icons that you used are just changing its colour. What I need is to change the whole icon not just the colour...the message icon tab shown on the pictures of the question when is unselected are different

    – Carlos Cabello Ruiz
    Mar 27 at 14:42

















Thanks for sharing but the icons that you used are just changing its colour. What I need is to change the whole icon not just the colour...the message icon tab shown on the pictures of the question when is unselected are different

– Carlos Cabello Ruiz
Mar 27 at 14:42






Thanks for sharing but the icons that you used are just changing its colour. What I need is to change the whole icon not just the colour...the message icon tab shown on the pictures of the question when is unselected are different

– Carlos Cabello Ruiz
Mar 27 at 14:42




















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%2f55305068%2fandroid-support-design-widget-bottomnavigationview-how-can-i-change-the-icon-of%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

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript