windowLayout = LayoutInflater.from(LiveActivity.this).inflate(R.layout.live_pop_more, null); window = new PopupWindow(windowLayout, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT); window.setFocusable(true); // 设置popWindow的显示和消失动画 window.setAnimationStyle(R.style.popwindow_anim_up_down_style); window.setOutsideTouchable(true); //这句是为了防止弹出菜单获取焦点之后,点击activity的其他组件没有响应 window.setBackgroundDrawable(new BitmapDrawable()); //popupwindow在指定位置显示 windowLayout.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); int popupWidth = windowLayout.getMeasuredWidth(); int popupHeight = windowLayout.getMeasuredHeight(); int[] location = new int[2]; // 获得位置 ivMore.getLocationOnScreen(location); window.showAtLocation(ivMore, Gravity.NO_GRAVITY, (location[0] + ivMore.getWidth() / 2) - popupWidth / 2, location[1] - popupHeight);
Android PopupWindow 相关设置
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.