W/InputEventReceiver: 已尝试完成输入事件,但输入事件接收器已被释放。在棒棒糖之前

W/InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed. on pre-Lollipop

当我尝试在 pre-Lollipop 上按下工具栏按钮时,它没有响应并且我得到以下日志输出: 07-20 16:31:59.797 25217-25217/io.github.delta.justreadit W/InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed. Android 牛轧糖一切都很好。我使用 Android 支持库 v26.

read.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <item
        android:id="@+id/changeFontFamily"
        android:icon="@drawable/ic_action_fontoptions"
        android:title="@string/view_settings"
        app:showAsAction="ifRoom" />
</menu>

onOptionsItemSelected 和 onCreateOptionsMenu

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.read, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case R.id.changeFontFamily:
            fontOptionsMenuWindow.showAsDropDown(findViewById(R.id.changeFontFamily));
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}

问题不存在。问题是因为 pre-Lollipop 和 Lollipop 的视图测量算法不同。我使用 ViewTreeObserver 设置 PopupWindow 的大小,因为我不知道 PopupWindow.setHeight 支持 WRAP_CONTENT。固定。