package com.hdl.photovoltaic.widget.popupview; import android.content.Context; import android.graphics.drawable.ColorDrawable; import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager; import android.widget.PopupWindow; /** * Author: Zoro * Date: 2018/11/23 * Description: This is BasePopView */ public abstract class BasePopView extends PopupWindow { public View mView; public Context mContext; public BasePopView(Context context, int layout) { super(context); this.mContext = context; initPopView(layout); } public BasePopView(Context context, int layout, int w, int h) { super(context); this.mContext = context; initPopView(layout, w, h); } public void initPopView(int layout, int w, int h) { mView = LayoutInflater.from(mContext).inflate(layout, null, false); setContentView(mView); setWidth(w); setHeight(h); this.setFocusable(true); this.setTouchable(true); this.setOutsideTouchable(true); this.setBackgroundDrawable(new ColorDrawable(0)); initContentView(mView); } public void initPopView(int layout) { initPopView(layout, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT); } // public void showPopView(View view) { // showAsDropDown(view, 0, 0); // } // // public void showPopView(View view, int x, int y) { // showPopView(view, x, y, Gravity.BOTTOM); // } // // public void showPopView(View view, int x, int y, int gravity) { // if (this.isShowing()) { // this.dismiss(); // } else { // this.showPopView(view, x, y, gravity); // } // } protected abstract void initContentView(View parent); }