public void showHintPopUpWindow(View view, Context context){
View layoutView= LayoutInflater.from(context).inflate(R.layout.t_menu_item_terminallist,null);
PopupWindow pw=new PopupWindow(layoutView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
TextView tv=layoutView.findViewById(R.id.log_item);
tv.setPadding(4,4,4,4);
pw.setOutsideTouchable(true);
pw.setBackgroundDrawable(new BitmapDrawable());
pw.setFocusable(true);
pw.setContentView(layoutView);
layoutView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
int popWidth=layoutView.getMeasuredWidth();
int popHeight=layoutView.getMeasuredHeight();
int [] location=new int[2];
view.getLocationInWindow(location);
pw.showAtLocation(view,Gravity.NO_GRAVITY,
location[0]+ view.getWidth()/2-popWidth/2,
location[1]+popHeight
);
}
网友评论