We're making an android app, and there is something we want to add. Which is the effect the Gmail app has.
You can choose which account you want to view (and the rest of the app will behave accordingly).
EDIT:
I now already have a (working) navigation bar, but the things I want are the round icons in the header. I want someone to be able to choose the user they are viewing.
You should use NavigationView
For this requirement You can check sample
MaterialDrawer
How To Make Material Design Navigation Drawer
Playing with NavigationView
Hope this helps .
I think this MaterialDrawer is what you're looking for. This library has a lot of examples. You can either use this library directly or read the source code and implement your own drawer.
The effect you want can be achieved by using
NavigationView
from thecom.android.support:design
support lib.You can find a full tutorial on that here. And you can download the full source code from that tutorial here.
And here's another nice tutorial that you could follow.
But long story short, that view is split between two main parts, a header and a menu part, and each one of those you'll have to define on XML.
As from that tutorial:
With that in mind, build your header as you would do with any other layout. And the Menu is defined somewhat like the Toolbar/ActionBar menu. e.g.:
navigation_menu.xml
Then, on your
Activity
you'll just have to make a layout like the one found in the tutorial, using theDrawerLayout
along withNavigationView
.You'll also have to create some
Fragments
for each screen you want to display with thisNavigationView
. After you've done that, on yourActivity
you can handle the selection events by implementingNavigationView.OnNavigationItemSelectedListener
, like this:As for your edit, the icons could be represented by an
ImageView
. And to navigate between multiple profiles, it depends on how you've implemented that logic on your app, but as a "generic" answer, you could switch those profiles using something like aSpinner
.Those tutorials will help you through that step:
Once you've set that up on your header, handle the item selection and change the user profile accordingly. (This last part depends ENTIRELY on how you've implemented user profiles on your app). But just as a head start, you could check the android training site, more specifically, this part.