使用PopupWindow由下向上弹出自定义窗口

final View view = getLayoutInflater().inflate(R.layout.pop_dialog, null);
PopupWindow pop = new PopupWindow(view, ViewGroup.LayoutParams.MATCH_PARENT,
				ViewGroup.LayoutParams.WRAP_CONTENT);
		pop.setOutsideTouchable(true);
		pop.setFocusable(true);// 点击back退出pop
		pop.setAnimationStyle(R.style.add_new_style);
		pop.setBackgroundDrawable(new ColorDrawable(0x33ff0000));// 设置背景透明,点击back退出pop
		addNew.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {

				if (pop.isShowing()) {
					pop.dismiss();
				} else {
					pop.showAtLocation(view, Gravity.BOTTOM, 0, -560);//在父控件下方出来
					// pop.showAsDropDown(view);
				}

			}
		});

styles.xml

动画效果

add_new_in.xml



    

add_new_out.xml



    







你可能感兴趣的:(Android笔记)