Title in ActionMode not showing

168 Views Asked by At

I have a problem that when set the title for the action mode for the first time, shortly after it is created, id doesn's show the title. Another request to do that works fine, only the first one. I do this by:

actionMode?.title = text

It is not the problem of actionMode not being initialized, because I checked it (if one closes the actionMode and opens it again, it works perfectly fine). Only the first title is not showing up. My actionMode is set to overlay the toolbar in my app theme like this:

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

If I set it to false, everything is working as it should, showing the title when it should be. But I really need this actionMode to be overlaying the toolbar.
Have anyone had a similar issue?

Also, the layout consists of CoordinatorLayout inside which there is a RecyclerView. If I wrap the RecyclerView in NestedScrollView the problem seems to disappear.

2

There are 2 best solutions below

0
baltekg On

I created a temporary fix for this, it is not solving the problem but it is working so it kinda does.

override fun onCreateActionMode(mode: ActionMode?, menu: Menu?): Boolean {
    mode?.menuInflater?.inflate(R.menu.action_menu, menu)
    mode?.title = "--" //temporary fix
    return true
}

Setting a title before I set the actual one seems to solve the issue. It doesn't work if the string is shorter than two characters.

0
shrimpcolo On

Recently, I also used the ActionMode with RecycleView, I referred to this article

https://medium.com/over-engineering/using-androids-actionmode-e903181f2ee3

FYI, http://prntscr.com/vr51b7