Show PopUpWindow at the top of Soft Keyboard
<p>I'm trying to show my PopUpWindow at the top of my edittext (with softkeyboard present) how can i do that? Consider my EditText has <code>android:maxLines="5"</code> and Y position is not always the same. This is what i got so far... </p>

<pre><code>private void createPopUpWindow() {
    View newView = getActivity().getWindow().getDecorView(); // this = activity

    int[] loc = new int[2];
    pivot.getLocationInWindow(loc);
    int topOfPivot = loc[1];

    Integer positionY = topOfPivot;
    popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    popupWindow.showAtLocation(newView, Gravity.BOTTOM, 0, positionY);

    frameLayout.getForeground().setAlpha(15);
    editText.setSelection(editText.getText().length());
}
</code></pre>

<p>Any suggestions?</p>

<p><a href="https://i.stack.imgur.com/4yPil.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4yPil.png" alt="Here is a little bit up"></a></p>

<p><a href="https://i.stack.imgur.com/fqxj1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fqxj1.png" alt="What am i doing wrong?"></a></p>