Question: I have simply Activity which is child of ActionBarActivity class. In the method I set OnCreate supported the toolbar. For this I override the OnOptionsItemSelected, so when I press the back button was performed some action

The code looks like this:

```
    [Activity (Label = "SimplyActivity", Theme="@style/MyTheme")]           
        public class SimplyActivity : ActionBarActivity
        {
            private Toolbar toolbar;

            // ... OnCreate method
            this.toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar (this.toolbar);
            SupportActionBar.SetDisplayHomeAsUpEnabled (true);
            SupportActionBar.SetHomeButtonEnabled (true);

            public override bool OnOptionsItemSelected (IMenuItem item)
            {
                if (item.TitleFormatted == null) this.OnBackPressed ();
                return base.OnOptionsItemSelected (item);
            }

```

Unfortunately, as long as the toolbar is displayed correctly, this is no longer any reaction when keys are pressed back. I would add that in other activities (which uses fragments) everything works correctly.

Please help me

Answer: 
Try something like this : 

Just add this lines in your `OnCreate` method:

```
  SupportActionBar.SetDisplayHomeAsUpEnabled(true);

```

Then override the `OnOptionsItemSelected` method as given below.

```
public override bool OnOptionsItemSelected(IMenuItem item)
{
    if (item.ItemId != Android.Resource.Id.Home)
        return base.OnOptionsItemSelected(item);
    Finish();
    return true;
}

```
The problem turned out to be really strange. Layout, which was using the action bar had RelativeLayout. After changing to LinearLayout attribute android:gravity = "vertical", everything works correctly.

Thanks all for help