Android 4.1+ PopupWindow 最简单的例子
Android 4.1+ PopupWindow Simplest Example
我想要简单明了的 PopupWindow 示例(如popupMenu)。
我想用 popupWindow 替换 popupMenu。
请帮忙
我解决了问题:
LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
PopupWindow popup = new PopupWindow(
inflater.inflate(R.layout.popup_window, null, false),
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
true
);
popup.showAtLocation(
findViewById(R.id.main),
Gravity.END | Gravity.TOP,
dpToPx(16),
dpToPx(42)
);
我想要简单明了的 PopupWindow 示例(如popupMenu)。
我想用 popupWindow 替换 popupMenu。
请帮忙
我解决了问题:
LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
PopupWindow popup = new PopupWindow(
inflater.inflate(R.layout.popup_window, null, false),
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
true
);
popup.showAtLocation(
findViewById(R.id.main),
Gravity.END | Gravity.TOP,
dpToPx(16),
dpToPx(42)
);