I have a popup that represents a circle, and I want it to be partially off-screen. To call the window, I used: popup.showAsDropDown(imageButton, OFFSET_X, OFFSET_Y);And it should look like this:

To copy the view I used: popup.setClippingEnabled(false);
And it works, it looks as I expect on devices with an API level below 21 ...
Unfortunately, on android L (candy), it looks like this:

The circle is cropped on top, but on the right side it just fits to the edge of the screen. Any ideas how to solve this problem?
I add the source code in which I call the popup
private void showPopup(final Activity context, ImageButton imageButton ) {
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();
final PopupWindow popup = new PopupWindow(layout);
popup.setContentView(layout);
popup.setWidth(popupWidth);
popup.setHeight(popupHeight);
popup.setFocusable(true);
int OFFSET_X =getResources().getDimensionPixelOffset(R.dimen.width_offset);
int OFFSET_Y = getResources().getDimensionPixelOffset(R.dimen.height_offset);
popup.setBackgroundDrawable(new BitmapDrawable());
popup.setClippingEnabled(false);
popup.showAsDropDown(imageButton, OFFSET_X, OFFSET_Y);
source
share