无法在Android Pie的键盘视图中显示弹出窗口

Pri*_*agb 14 android popupwindow android-9.0-pie

我正在制作一个显示popupWindow语言的键盘。在所有设备上,我都可以popupWindow在键盘外完美显示,但在仅Android Pie中,不能popupWindow在键盘外显示。

candidateView连接蓝牙键盘时,我想在键盘之外显示弹出窗口。

我正在使用此代码

setClippingEnabled(false);
showAtLocation(anchor, Gravity.NO_GRAVITY, x, y);
Run Code Online (Sandbox Code Playgroud)

有人有什么想法吗,这是什么问题?

这是演示应用程序-https: //github.com/priyankagb/andoidpiepopupwindowdemo

看截图

在Android Pie中,您可以在底部看到一小行popupWindow用于语言

左边是馅饼下方,右边是馅饼

Pri*_*agb 3

是的,我已经通过更改键盘的布局文件解决了我的问题

我在候选视图上方添加了一个虚拟视图

喜欢...

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <View
        android:layout_width="match_parent"
        android:layout_height="250dp"
        android:layout_marginBottom="8dp"
        app:layout_constraintBottom_toTopOf="@+id/rlPredictionView" />

    <RelativeLayout
        android:id="@+id/rlPredictionView"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="@drawable/background_with_shadow_prediction_bar"
        android:visibility="visible"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent">

        ...

    </RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

InputMethodService而不是在类中重写此方法

 @Override
    public void onComputeInsets(InputMethodService.Insets outInsets) {
        super.onComputeInsets(outInsets);
        outInsets.visibleTopInsets = candidateView.getRelativeView().getTop();
        outInsets.contentTopInsets = candidateView.getRelativeView().getTop();
    }
Run Code Online (Sandbox Code Playgroud)

上面的虚拟视图rlPredictionView将设置visibleTopInsets键盘,在此区域中,弹出窗口将显示

该虚拟视图将允许在触摸时访问背景视图,因此用户看不到

参考 - /sf/answers/3732875051/