Action bar number like Gmail

I am trying to display the amount of data in the upper right corner of my action bar.

If I had not used the split action bar, I would simply have created a TextView in the bar, but it is currently not possible to have elements at the top of the Action Bar when you split.

To clarify, I mean the following:

Gmail unread count

Did Google use a different implementation of the action bar, or is there a way to do this? I think I remember reading about it, but I can’t find what it's called.

+14
android android-actionbar
May 25 '12 at 03:17
source share
2 answers

Use a custom view with your counter and text view for the top AB, and include android:uiOptions="splitActionBarWhenNarrow" in the manifest declaration for your activity.

 //set the actionbar to use the custom view (can also be done with a style) getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); //set the custom view to use getActionBar().setCustomView(R.layout.custom_ab); 

Where custom_ab.xml is the layout with your ImageView, Spinner and TextView for counting.

+25
Aug 30 2018-12-12T00:
source share

You should stop using the ActionBar or like it and update the application to use the toolbar, which has a simple and convenient interface to do whatever you can think of. To read about it, use [Android Blog] [1]

[1]: http://android-developers.blogspot.in/2014/10/appcompat-v21-material-design-for-pre.html for prelop applications.

0
May 14 '15 at 12:15
source share



All Articles