why getWindowVisibleDisplayFrame get value is Rect(-10000, -10000 - 10000, 9324)

Viewed 70

I do it in my PopupWindow, this is my code:

public class MyPane extends PopupWindow implements  ViewTreeObserver.OnGlobalLayoutListener  {
    boolean m_isKeyboardShowing = false;
    ConstraintLayout view;
    EditText m_editTx;

    public MyPane(Bitmap bitmap, Context context) {
        super(context);
        super.setIsClippedToScreen(true);
        // create view and create m_editTx...
        view.getViewTreeObserver().addOnGlobalLayoutListener(this);
    }

    @Override
    public void onGlobalLayout() {
        Rect rt = new Rect();
        view.getWindowVisibleDisplayFrame(rt);
        int keyboardHeight = view.getHeight() - rt.height();
        if (keyboardHeight <= 0.25 * view.getHeight()) {
            if (m_isKeyboardShowing) {
                m_isKeyboardShowing = false;
            }
        } else {
            if (!m_isKeyboardShowing) {
                m_isKeyboardShowing = true;
            }
        }
    }
}

when i use super.setIsClippedToScreen(true);,the rt get Rect(-10000, -10000 - 10000, 9324), but when i remove super.setIsClippedToScreen(true); i can get right result, but i can not remove super.setIsClippedToScreen(true); because it doesnt cover the whole screen if remove. so how can i do?

Edit: I found that setIsClippedToScreen do the thing that set curFlags |= WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;

0 Answers
Related