我想制作一个自定义键盘.我不知道如何在xml和activity中做到这一点.这张照片是我的键盘型号.它只需要数字.

我做了一个自定义键盘.当您长按一个键时,会PopupWindow在键上方显示一些额外的选项.问题是在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)