How to make contextual actionmode bar overlay my layout instead of "pushing" it down
Asked Answered
R

3

43

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.

Image 1

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.

Image 2

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.

Image 3

Is that possible?

Rascon answered 4/7, 2013 at 14:47 Comment(0)
G
57

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

Gilstrap answered 21/7, 2013 at 15:9 Comment(7)
O.M.G. This one was of the type "How can anyone miss that?". Worked like a charm, thank you very much!!!Rascon
i didn't work for me. i am using "Theme.AppCompat.Light.NoActionBar" and a toolbarTumescent
i have same issue but this answer didnt help. i have a listview and i show cab(contextual action bar ) when user selects an item. so if i select first item i the list , the cab is displayed and item s checkbox is checked but the view is pushed up. The last page of list will be visible and i have to scroll up to see the first item that was selected. Further selecting items do not push view as cab is already present.Margaritamargarite
Dudes, it didn't work for me neither until i notice that i was testing on API 23 and i set that <item> in valuesand not in values-21 too..Jonijonie
@Tumescent if use with AppCompatActivity, you should use <item name="windowActionModeOverlay">true</item> ( no android: prefix)Nonconcurrence
@lazybug Thank you for your valuable comment.Wickiup
@lazybug you are an MVP. shall i buy you a beer?Chambray
H
38

To use windowActionModeOverlay with appcompat toolbar,use

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

to your style.

Hunch answered 18/2, 2015 at 12:37 Comment(1)
Maybe this should be turned into the accepted answer instead. I don't think AppCompat even was a thing when I posted the original answer in '13.Gilstrap
F
3

This can also be done programmatically using:

 getWindow().requestFeature(Window.FEATURE_ACTION_MODE_OVERLAY);
Fiore answered 12/8, 2015 at 15:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.