• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps android L (lollipop) popup window out of screen (clipping does not work)

Artorgoo

Lurker
I have popup window which is a circle and I want it to be partially out of screen bounds. To invoke window I used: `popup.showAsDropDown(imageButton, OFFSET_X, OFFSET_Y);` And it should looks like this:

XyDkY.png


To clip a view I used: `popup.setClippingEnabled(false);`
And it works, it looks as I expect on devices with API level below 21...

Unfortunately, on android L (lollipop) it looks like this:

Qzdze.png


Circle is clipped on top, but on right side it just come to the edge of screen. Any ideas how to solve this problem?

I attach source code in which I invoke popup window


Java:
private void showPopup(final Activity context, ImageButton imageButton ) {
        // Inflate the popup_layout.xml
        FrameLayout viewGroup = (FrameLayout) context.findViewById(R.id.popup);
        final LayoutInflater layoutInflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        final View layout = layoutInflater.inflate(R.layout.popup, viewGroup);
     
        layout.startAnimation(range_animation_start);
     
        layout.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
     
        int popupHeight = layout.getMeasuredHeight();
        int popupWidth = layout.getMeasuredWidth();
        // Creating the PopupWindow
        final PopupWindow popup = new PopupWindow(layout);
        popup.setContentView(layout);
        popup.setWidth(popupWidth);
        popup.setHeight(popupHeight);
        popup.setFocusable(true);
     

        // Some offset to align the popup a bit to the right, and a bit down, relative to button's position.
        int OFFSET_X =getResources().getDimensionPixelOffset(R.dimen.width_offset);
        int OFFSET_Y = getResources().getDimensionPixelOffset(R.dimen.height_offset);
     
       // Clear the default translucent background
        popup.setBackgroundDrawable(new BitmapDrawable());
        popup.setClippingEnabled(false);
     
        // Displaying the popup at the specified location, + offsets.
     
        popup.showAsDropDown(imageButton, OFFSET_X, OFFSET_Y);
 
Back
Top Bottom