Xamarin Android ActionMode context bar in appcompat-v7 toolbar not getting dropped when API button is clicked 21

I am facing the following strange error in my Android Xamarin.

I have an EditText field that uses Theme.AppCompat.Light.NoActionBar in the AppCompatActivity class, I have set up a minimal project API targeting API 15. I am currently using AppCompat-v7 25.1.1.

The app shows the contextual ActionMode bar on long press on the EditText, usually on Android API <21 and> 22, but for some strange reason API 21 and 22, the action bar is not completely discarded.

The icons can be seen in the toolbar and are not viewable. If the drawer is open, the toolbar returns to its normal state.

Context bar ActionMode

Action button pressed back.

This is my topic:

<style name="Theme.Base.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/Purple</item>
<item name="colorPrimaryDark">@color/CustomPurpleDark</item>
<item name="colorAccent">@color/Blue</item>
<item name="windowActionModeOverlay">true</item>
<item name="actionModeBackground">?attr/colorPrimaryDark</item>

      

In class I

_toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.Toolbar);
SetSupportActionBar(_toolbar);
_toolbar.StartActionMode(this); //I have added this so I can listen to the ActionMode.ICallback interface methods 

      

I also added

    public bool OnActionItemClicked(ActionMode mode, IMenuItem item)
    {
        if (item.ItemId == Resource.Id.home)
        {
            mode.Finish();
        }
        return true;
    }

    public bool OnCreateActionMode(ActionMode mode, IMenu menu)
    {
        _actionMode = mode;
        return true;
    }

    public void OnDestroyActionMode(ActionMode mode)
    {
        _actionMode.Finish();
        _actionMode = null;
    }

    public bool OnPrepareActionMode(ActionMode mode, IMenu menu)
    {
        return true;
    }

      

Does anyone know why this is happening? Any help would be greatly appreciated.

+3


source to share





All Articles