How to make contextual actionmode bar overlay my l

2020-05-19 04:23发布

问题:

I have implemented my own viewgroup for my application. Using actionbar is not an option for various reasons so in my viewgroup I have my own "actionbars" one on top and one in the bottom. Image 1 illustrates my current layout.

As you can see there are two edittexts in the layout and everything looks ok.

However when the user selects some text in any of the edittexts the contextual actionmode bar is shown. Image 2 illustrates this.

When this happens actionmode bar "pushes" down my entire layout in order to get its space. In tablets and other large screen devices this is OK but in smaller devices and especially with the soft keyboard visible the remaining height is too small (in landscape orientation is unusable).

What I want to do is actionmode bar to overlay my layout instead of pushing it down as shown in Image 3.

Is that possible?

回答1:

Just add <item name="android:windowActionModeOverlay">true</item> to your style.



回答2:

To use windowActionModeOverlay with appcompat toolbar,use

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

to your style.



回答3:

This can also be done programmatically using:

 getWindow().requestFeature(Window.FEATURE_ACTION_MODE_OVERLAY);