Search code examples
androidandroid-toolbarandroid-actionmodeactionmode

Android - ActionMode after landscape the Toolbar becomes visible and does not hide


I have a root view and this root view contains a fragment with viewpager. This is my ContentFragment. And I update view of this ContentFragment for viewpager behaviour. Now, when I activated ActionMode for a view of ContentFragment, the ActionMode initially hides the Toolbar of root view which is desired result like below:

enter image description here

Unfortunately after landscape mode the Toolbar becomes visible again and does not hide. Check below image:

enter image description here

And after that I always get the following view in ActionMode even if I put the device upright:

enter image description here

instead of this: (desired view)

enter image description here

When I manually hide Toolbar by using this line of code:

toolbar.visibility = View.INVISIBLE

or

toolbar.visibility = View.GONE

inside root view, then the ActionMode overlaps first item of ListView like below:

enter image description here

I have

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

used in themes.xml and I'm sure. But the question is why does ActionMode initially hide the Toolbar, but after landscape mode the Toolbar becomes visible again and never hides.


Solution

  • Fixing actionBarSize to the toolbar height resolved my issue. I just added

    <item name="actionBarSize">@dimen/toolbar_action_mode_height</item>
    

    to my themes. And issue resolved.