Georgian Benetatos
Georgian Benetatos

Reputation: 728

Android navigation button including title like Facebook

How can I make the back navigation button contain the activity title?

This is my code, and when I click back, it only clicks in the arrow.

I know how to provide back navigation. I would like to know how I can include the title in the button!

Toolbar toolbar = (Toolbar) findViewById(R.id.activity_alarms_toolbar);
    toolbar.setTitle("Alarms");
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });

Facebook screenshot

Upvotes: 0

Views: 206

Answers (1)

Raghunandan
Raghunandan

Reputation: 133560

I just took a look at the facebook about screen on Nexus 5 lollipop.

I used a uiautomaterview

So it looks like

enter image description here

Looking at the root layout at the top is a RelativeLayout.

Then you have the LinearLayout hosting the ImageView and Textview.

So the click is on the LinearLayout. On click of it navigation back.

Your toolbar is a view group you can probably add the relative layout to the toolbar.

Upvotes: 2

Related Questions