Number in Action Bar like Gmail

前端 未结 2 1366
别那么骄傲
别那么骄傲 2020-12-23 00:27

I\'m trying to display a data count in the top right corner of my Action Bar.

If I wouldn\'t be using a split action bar I would just create a TextView in the bar, b

相关标签:
2条回答
  • 2020-12-23 00:43

    Use a custom view with your spinner and text view for the top AB and enable the 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 a layout with your ImageView, Spinner and TextView for the count.

    0 讨论(0)
  • 2020-12-23 00:53

    You should stop using ActionBar or like and update your app to use Toolbar which has a simple and much easy interface to do the everything you can think of. For reading about it use the [Android Blog][1]

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

    0 讨论(0)
提交回复
热议问题