0

I want to have a Switch in the Bottom Navigation to set the online/offline state of the user like below Image:

enter image description here

The menu itself should be dynamic so i built it manually with:

menu.add(Menu.NONE, R.id.navigation_dashboard, Menu.NONE, "").setIcon(R.drawable.ic_app)

Is there a way to achieve this and add a switch to this? I accomplished the this in iOS by setting a switch to the frame of the bottom navigation bar item.

Md. Zakir Hossain
  • 1,082
  • 11
  • 24
Thomas
  • 1
  • 3

1 Answers1

0

Are you asking about having the button color change, when that item is selected? If so, this is done automatically for you, using the BottomNavigationView component.

Do be aware, that you will need to supply a "StateListDrawable" (this is a fancy way to say list of icons, that represent different selected states) instead of just a drawable for this icon: https://developer.android.com/reference/android/graphics/drawable/StateListDrawable

Booger
  • 18,579
  • 7
  • 55
  • 72