3

The Contextual ActionBar doesn't integrate with the toolbar, like it did with the ActionBar. It will appear above the toolbar. This can be fixed by placing

`<item `name="windowActionModeOverlay">true</item>` 

inside styles.xml

The problem is that while the CAB now overlays the toolbar, that's all it does. This means, that I can still interact with the toolbar when in action mode.

I have included a picture of the problem below. Here you can see that the spinner found on the toolbar, still comes up when I press area where the spinner is located on the toolbar.

enter image description here

Is there a way to fix this?

Cœur
  • 37,241
  • 25
  • 195
  • 267
HaloMediaz
  • 1,251
  • 2
  • 13
  • 31

2 Answers2

1

Solution

hide the toolbar when actionmode is first created. Do not set View.GONE, as this will remove the space of the toolbar. Instead user View.INVISIBLE. This keeps the toolbar space.

@Override
    public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
        getActivity().getMenuInflater().inflate(R.menu.contextual_action_bar, menu);
        toolbar.setVisibility(View.INVISIBLE);

        return true;
    }

Make toolbar visible when action mode is destroyed.

@Override
    public void onDestroyActionMode(ActionMode mode) {
        this.mActionMode = null;
        toolbar.setVisibility(View.VISIBLE);
    }
HaloMediaz
  • 1,251
  • 2
  • 13
  • 31
0

You should use android:dropDownVerticalOffset="60dp"

<Spinner
    android:id="@+id/toolbar_spinner"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:dropDownVerticalOffset="60dp"
    android:dropDownWidth="match_parent"
    android:spinnerMode="dropdown" />
Ziem
  • 6,579
  • 8
  • 53
  • 86
msevgi
  • 4,828
  • 2
  • 24
  • 30