Android PopupWindow的简单使用。
View view=View.inflate(this, tcking.github.com.giraffeplayer.R.layout.text,null);
//第一个参数为要显示的view,后边为popuwindown的宽和高,也可以是具体数值
PopupWindow pupWindow = new PopupWindow(view, ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT);
pupWindow.setFocusable(true);//是否需要获取焦点
pupWindow.setOutsideTouchable(true);//点击外边是否可以取消
pupWindow.setBackgroundDrawable(new BitmapDrawable());//设置背景图片
//在控件V某个位置显示,有LEFT,BOTTOM,TOP。后边是在x方向偏移的距离,和在y方向的偏移的距离
pupWindow.showAtLocation(v, Gravity.RIGHT, location[0], location[1]-popupWindow.getHeight());
//在控件V正下方显示
pupWindow.showAsDropDown(v);//在正下方显示
//取消
pupWindow.dismiss();