【发布时间】:2018-08-23 07:13:31
【问题描述】:
我不知道如何在 Android 中进行水平弹出。我想做这样的事情:
我已经写了这段代码:
public void onPopUp(View view) {
LayoutInflater layoutInflater = (LayoutInflater) this.getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
final View popupView = layoutInflater.inflate(R.layout.popup, null);
final PopupWindow popupWindow = new PopupWindow(
popupView,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT, true);
popupWindow.setOutsideTouchable(true);
popupWindow.setFocusable(true);
popupWindow.setBackgroundDrawable(new BitmapDrawable());
View parent = view.getRootView();
popupWindow.showAtLocation(parent, Gravity.CENTER, 100, 50);
}
但是弹出窗口是透明的,根据我使用的设备放置得不好,直到我点击两次才会消失。
如果您有任何想法或我做错了什么,请告诉我!
【问题讨论】:
-
请向我们展示您到目前为止所做的尝试。我们无法为您编写完整的解决方案。感谢理解。
-
是的没问题!