Search code examples
android-studioandroid-appbarlayout

How to have activity that produce more than one layout when hitting button


Most of us saw the bottom bar in telegram , facebook messenger .. I think . What i want to know " how is that bar still appear even if we go to another view ? Thanks in advance .


Solution

  • After reading your comment I understand what you meant. You may want to learn about Fragments, and FragmentActivity. Basically, you would have multiple fragments for each button on the Bottom Navigation, meaning you would have multiple classes and layouts. Your activity's layout should have a container (above the bottom navigation, in a FrameLayout for example) on which you can attach your Fragment. When you hit a button on the bottom navigation, you switch fragments.