工作过程中记录一下,以免掉头就忘。
private void initPopupWindow() {
View contentView = LayoutInflater.from(getContext()).inflate(R.layout.popupwindow_list_money, null);
mPopupWindow = new PopupWindow(contentView,LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
mPopupWindow.setOutsideTouchable(true);
mPopupWindow.setFocusable(true);
mPopupWindow.setTouchInterceptor(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
//此处监听setOutsideTouchable(true)和内容上的点击事件
return false;
}
});
float density = getResources().getDisplayMetrics().density;
mPopupWindow.setWidth((int) (90*density));
mPopupWindow.setHeight((int) (230*density));
mPopupWindow.setAnimationStyle(android.R.style.Animation_Toast);
mPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT))