I want to change the size of only ONE icon (3rd icon) out of the 5 icons I have used in my bottom navigation view.
I want The Center icon big like:
This is what I have tried:
private fun setReportPainIconSize(){
val bottomNavigationView =
findViewById<BottomNavigationView>(R.id.navigationBottomView)
val menuView: BottomNavigationMenuView =
bottomNavigationView.getChildAt(0) as BottomNavigationMenuView
val iconView: View = menuView.getChildAt(2) **//TO GET REFERENCE OF 3RD ITEM**
.findViewById(androidx.core.R.id.icon)
val layoutParams: ViewGroup.LayoutParams = iconView.layoutParams
val displayMetrics: DisplayMetrics = resources.displayMetrics
layoutParams.height = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 47F,
displayMetrics
).toInt()
layoutParams.width = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 44F,
displayMetrics
).toInt()
iconView.layoutParams = layoutParams
}
But on running my app crashes and the error message I get is :
Caused by: java.lang.NullPointerException: menuView.getChildAt(2)
…(androidx.core.R.id.icon) must not be null
How do I accomplish it? ? Pls help!