final View inflate = View.inflate(this, R.layout.layout, null); p = new PopupWindow(inflate,100,100); p.setTouchable(true); p.setFocusable(true); p.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.cc))); p.showAtLocation(inflate, Gravity.CENTER,0,0); p.showAsDropDown(inflate,100,100);
PopupWindow 简单实用(居中显示)
最新推荐文章于 2025-09-23 11:06:10 发布
本文介绍了如何使用Android中的PopupWindow组件创建弹出窗口。通过LayoutInflater加载布局,并设置PopupWindow的尺寸、触摸反馈、焦点属性及背景颜色。展示了如何将PopupWindow显示在屏幕中心位置或作为下拉菜单形式出现。
1119

被折叠的 条评论
为什么被折叠?



