相关疑难解决方法(0)

PopupWindow在Android API 28的自定义键盘上被剪辑

我做了一个自定义键盘.当您长按一个键时,会PopupWindow在键上方显示一些额外的选项.问题是在API 28中,此弹出窗口被剪裁(甚至完全隐藏在顶行).

在此输入图像描述

我已经解决了这个问题API <28

popupWindow.setClippingEnabled(false);
Run Code Online (Sandbox Code Playgroud)

但是,对于API 28,问题又回来了.这是更多的代码:

private void layoutAndShowPopupWindow(Key key, int xPosition) {
    popupWindow = new PopupWindow(popupView,
            LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    popupWindow.setClippingEnabled(false);
    int location[] = new int[2];
    key.getLocationInWindow(location);
    int measureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    popupView.measure(measureSpec, measureSpec);
    int popupWidth = popupView.getMeasuredWidth();
    int spaceAboveKey = key.getHeight() / 4;
    int x = xPosition - popupWidth / popupView.getChildCount() / 2;
    int screenWidth = getScreenWidth();
    if (x < 0) {
        x = 0;
    } else if (x + popupWidth > screenWidth) {
        x = …
Run Code Online (Sandbox Code Playgroud)

android android-popupwindow custom-keyboard

11
推荐指数
1
解决办法
990
查看次数