CustomPopup
新建SimpleCustomPop 继承BasePopup
private class SimpleCustomPop extends BasePopup<SimpleCustomPop> {
private TextView mTvItem1;
public SimpleCustomPop(Context context) {
super(context);
}
@Override
public View onCreatePopupView() {
//加载poupwind里布局文件
View inflate = View.inflate(mContext, R.layout.popup_custom, null);
mTvItem1 = (TextView) inflate.findViewById(R.id.tv_item_1);
return inflate;
}
@Override
public void setUiBeforShow() {
//设置点击事件
mTvItem1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
}
弹出poupwindow
SimpleCustomPop mQuickCustomPopup = new SimpleCustomPop(mContext);
mQuickCustomPopup
.alignCenter(true)//是否是控件居中对齐
.anchorView(mTvCenter)//控件
.gravity(Gravity.BOTTOM)//居控件的底部 只能选TOP和BOTTOM
.showAnim(new SlideTopEnter()) //显示动画 BounceTopEnter BounceBottomEnter
.dismissAnim(new SlideTopExit()) //消失动画
.offset(0, 0) //第一个参数 距左边的距离 第二个参数 居控件的距离
.dimEnabled(false)
.show();
BubblePopup
更简单
//加载布局 可以找到控件 设置控件里的参数
View inflate = View.inflate(MainActivity.this, R.layout.popup_bubble_image, null);
BubblePopup bubblePopup=new BubblePopup(MainActivity.this,inflate);
bubblePopup.anchorView(mTvCenter)//控件
.gravity(Gravity.BOTTOM)
.showAnim(new SlideRightEnter())
.dismissAnim(new SlideLeftExit())
.autoDismiss(false)//是否自动消失
.show();