1

Unlike previous questions to customize actionbar as [A][B] ACTION_BAR or [A] ACTION_BAR [B],

I'd like to make [LOGO][A] ACTION_BAR [B][C] style. One button "A" is placed right-side of the logo (but left aligned) where normally title text is placed. (Note that A,B,C are buttons)

Is there another way except to use setCustomView()? small changes but replacing whole actionbar view makes lot of works.

Maybe a kind of overlaid button view and logo width value can help or replace title textview to ButtonView also can make it, but I hardly imagine how to acheive.

Community
  • 1
  • 1
Youngjae
  • 24,352
  • 18
  • 113
  • 198
  • the best way to achieve this is really using setCustomView(), it's easy to achieve it with just one layout. The second option which I can think is to create the logo + button and place it as your logo and override home button onClick. But that means when user click the button your icon will be highlighted too. – hardartcore May 08 '13 at 06:44
  • @Android-Developer // Thanks for the feedback. I'll try and will post my code later. – Youngjae May 08 '13 at 10:17

1 Answers1

3

Right side of the button:

 //Inflate the custom view
    View customNav = LayoutInflater.from(this).inflate(R.layout.custom_view, null);

    //Bind to its state change
    ((Button)customNav.findViewById(R.id.button)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // DO your stuff

        }
    }); 

    //Attach to the action bar
    getSupportActionBar().setCustomView(customNav);
    getSupportActionBar().setDisplayShowCustomEnabled(true);
Nilesh Verma
  • 914
  • 1
  • 11
  • 26