package com.anysoftkeyboard.keyboards.views.preview;

import android.graphics.Point;
import android.view.View;
import com.anysoftkeyboard.keyboards.Keyboard;

public class AboveKeyboardPositionCalculator implements PositionCalculator {
    @Override
    public Point calculatePositionForPreview(
            Keyboard.Key key, View keyboardView, PreviewPopupTheme theme, int[] windowOffset) {
        // center of the top of the keyboard
        return new Point(
                keyboardView.getLeft() + keyboardView.getWidth() / 2, keyboardView.getTop());
    }
}

@@ -78,16 +78,46 @@
 .Point;%0A
+import android.graphics.Rect;%0A
 import a
@@ -427,163 +427,277 @@
     
-// center of the top of the keyboard%0A        return new Point(%0A                keyboardView.getLeft() + keyboardView.getW
+Point point = new Point(key.x + windowOffset%5B0%5D, windowOffset%5B1%5D);%0A%0A        Rect padding = new Rect();%0A        theme.getPreviewKeyBackground().getPadding(padding);%0A%0A        point.offset((key.w
 idth
-()
  / 2
+)
 , 
-keyboardView.getTop())
+padding.bottom - theme.getVerticalOffset());%0A%0A        return point
 ;%0A  

Fix AnySoftKeyboard/AnySoftKeyboard#2554