ShowAtLocation方法用于将View显示在指定的位置上,具体使用方法如下:
获取要显示的View对象:View view = findViewById(R.id.your_view_id);获取要显示的位置的父View对象:View parentView = findViewById(R.id.parent_view_id);设置要显示的View的布局参数:ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);view.setLayoutParams(layoutParams);调用ShowAtLocation方法显示View:int x = 100; // x坐标int y = 200; // y坐标popupWindow.showAtLocation(parentView, Gravity.NO_GRAVITY, x, y);通过以上步骤,就可以将指定的View显示在指定的位置上。


