PopupWindow overrides soft buttons on Android 5.0

I have a simple PopupWindow that I create using the following code (the code is in C #, the Java code should be basically the same)

 View popupView = LayoutInflater.From(this.Activity).Inflate(Resource.Layout.LectionFooter, null); var popup = new PopupWindow(popupView, ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent, false) { OutsideTouchable = true, AnimationStyle = Resource.Style.FooterAnimation }; popup.SetBackgroundDrawable(new BitmapDrawable()); popup.ShowAtLocation(rootView, GravityFlags.Bottom, 0, 0); 

On devices with a preliminary Lollipop, this pop-up window looks great, but on Android 5.0, the pop-up window overlaps the soft buttons:

PopupWindow Lollipop

Here's PopupWindow on an Android 4.4 device:

enter image description here

Does anyone have an idea why this is happening and how can this be fixed?

+7
android
source share
1 answer

This is a possible error in android api 21, so they implemented the popup.setAttachedInDecor (true / false) method ; in api 22 however there is a workout, you can set the correct y coordinate for your popup as follows:

 Rect rect = new Rect(); getWindow().getDecorView().getWindowVisibleDisplayFrame(rect); int winHeight = getWindow().getDecorView().getHeight(); popup.showAtLocation(rootView, Gravity.BOTTOM, 0, winHeight-rect.bottom); 
+16
source share

All Articles