PopupWindow学习总结

来源:互联网 发布:protobuf java any 编辑:程序博客网 时间:2024/05/28 15:07
 

PopupWindow学习总结

经过一段时间的学习,了解了PopupWindow的基本用法,如下:

1PopupWindowview布局,通过LayoutInflator获取布局的view.:

LayoutInflater inflater =(LayoutInflater)             this.anchor.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

View textEntryView =  inflater.inflate(R.layout.paopao_alert_dialog, null);

       

2、显示位置,可以有很多方式设置显示方式

pop.showAtLocation(findViewById(R.id.ll2), Gravity.LEFT, 0, -90);

3、进出场动画

pop.setAnimationStyle(R.style.PopupAnimation);

4、点击PopupWindow区域外部,PopupWindow消失

   this.window = new PopupWindow(anchor.getContext());

this.window.setTouchInterceptor(new OnTouchListener() {

@Override

public boolean onTouch(View v, MotionEvent event) {

if(event.getAction() ==                                                                 MotionEvent.ACTION_OUTSIDE) {              

BetterPopupWindow.this.window.dismiss();

return true;

}

return false;

}

});

     

原创粉丝点击