The navigation bar has 4 buttons, all of color gray. Each one inflates a specific fragment. when clicked on it,it changes its color to red.
The button which is clicked is also becoming larger(bigger).I want to change the color(gray to red) but not size
.
How to achieve this (not changing the size of button)?
Thanks in advance.
The following is the part of the code:
Menu xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/navigation_home"
android:icon="@drawable/ic_feed"
android:title=""/>
<item
android:id="@+id/navigation_dashboard"
android:icon="@drawable/ic_analytics"
android:title="" />
<item
android:id="@+id/navigation_profile"
android:icon="@drawable/ic_profile"
android:title="" />
<item
android:id="@+id/navigation_settings"
android:icon="@drawable/ic_settings"
android:title="" />
</menu>
kotlin code:
private lateinit var bottomnav : BottomNavigationView
val navUtils = NavigationUtils()
private val mOnNavigationItemSelectedListener =
BottomNavigationView.OnNavigationItemSelectedListener { item ->
when (item.itemId) {
R.id.navigation_home -> {
val locationhistoryinstance =
LocationHistoryFragment.newInstance()
loadFragment(locationhistoryinstance)
setTitle("Calender Test")
return@OnNavigationItemSelectedListener true
}
R.id.navigation_dashboard -> {
val analyticsinstance = AnalyticsPageFragment.newInstance()
loadFragment(analyticsinstance)
setTitle("Analytics")
return@OnNavigationItemSelectedListener true
}
R.id.navigation_profile -> {
val profileinstance = ProfileFragment.newInstance()
loadFragment(profileinstance)
setTitle("Profile")
return@OnNavigationItemSelectedListener true
}
R.id.navigation_settings -> {
val settingsinstance = SettingsFragment.newInstance()
loadFragment(settingsinstance)
setTitle("Settings")
return@OnNavigationItemSelectedListener true
}
}
false
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_home)
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener)
bottomnav = findViewById(R.id.navigation)
navUtils.disableShiftMode(bottomnav)
}