How to set drawings in the action bar of my Android application

I am developing an application in which I have to put shortcuts on top of the action bar and update from time to time. Here is the layout I want it to look like.

ActionBar Drawable on top

I want to put an ejected one, as shown in the picture, attached (the green color can be drawn, not the notification thing). Is it possible to achieve this kind of screen in android? If so, please help me how to achieve this.

Any help would be appreciated.

+5
source share
2 answers

It is easy to use custom view. Let me briefly explain the steps for you:

  • Create your custom view in the layout folder. Eg ImageButton.

  • . ,

    getSupportActionBar().setCustomView(R.layout.your_custom_view);
    

    ( getActionBar() getSupportActionBar())

  • setDisplayOptions() ActionBar.DISPLAY_SHOW_HOME ActionBar.DISPLAY_SHOW_CUSTOM.

  • , .

  • , OnClickListener .

, , !

+3
  • ActionView ActionBar
  • onCreateOptionsMenu
0

All Articles