PopupWindow的简单设置

//设置Popuwindow出现在什么位置
popupWindow.showAsDropDown(v);

//popupWindow的样式,睡醒
private void initPopupWindow(){
View view = View.inflate(getActivity(), R.layout.popwindow_layout, null);
popRec = (RecyclerView)view.findViewById(R.id.pop_rec);
popRel = (RecyclerView)view.findViewById(R.id.pop_rel);

    popupWindow = new PopupWindow(view, ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.WRAP_CONTENT);

// 设置外部响应事件
popupWindow.setOutsideTouchable(true);
// 设置此点击事件获得焦点
popupWindow.setFocusable(true);
// 设置背景颜色
ColorDrawable colorDrawable = new ColorDrawable(getResources().getColor(R.color.pop_color));
popupWindow.setBackgroundDrawable(colorDrawable);

}

猜你喜欢

转载自blog.csdn.net/black_amber/article/details/90748087