1.showAtLocation必须在activity完全的运行后使用,否则会报错 android.view.WindowManager$BadTokenException:Unable to add window -- token null is not valid; is your activity running?
解决:通过延迟
new Handler().postDelayed(new Runnable(){ public void run() { mPopupWindow.showAtLocation(parent,gravity,x,y); } }, 200L);
2.和EditText 一起使用bug
解决:
三方的:
com.github.razerdp:BasePopup:2.2.0