In Bottom Navigation Bar , icon is not getting highlighted even after i selected that icon .How to change it?

拟墨画扇 提交于 2021-02-08 11:22:44

问题


By default in every activity only home icon is getting highlighted.

  1. How to change the highlight the icon which is selected ?
  2. How to change the default highlighting icon ?
  3. Where to make the changes in which activity_main.xml or MainActivity.java or else menu xml file ?

Login icon is pressed but home is getting highlighted : selector.xml

MainActivity.java

activity_main.xml

nav_items.xml-menu item I pressed the second icon,activity is changed but still home is getting highlighted in emulator


回答1:


Try this

Add a selector.xml in drawable folder like

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

In activity_main.xml add app:itemIconTint="@drawable/selector"

 <android.support.design.widget.BottomNavigationView

    app:itemIconTint="@drawable/selector"

    />


来源:https://stackoverflow.com/questions/51257473/in-bottom-navigation-bar-icon-is-not-getting-highlighted-even-after-i-selected

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!