如何让popupwindow 显示在整个屏幕的中央
2018-02-27 · 知道合伙人互联网行家
public static void showShareWindow(Activity activity, View parentView, String pageName){ View mContentView = null; V5ShareView mShareView = null; if(mContentView == null){ mContentView = LayoutInflater.from(activity).inflate(R.layout.v5_share_layout, null); } if(mPopUpWindow == null){ mPopUpWindow = new PopupWindow(mContentView, LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT); mPopUpWindow.setBackgroundDrawable(new BitmapDrawable()); mPopUpWindow.setOutsideTouchable(true); mPopUpWindow.setFocusable(true); } if(mShareView == null){ mShareView = new V5ShareView(mContentView,pageName,activity); } mShareView.setOnShareViewDismiss(new ShareViewDismiss() { @Override public void dismiss() { mPopUpWindow.dismiss(); } }); mPopUpWindow.showAtLocation(activity.getWindow().getDecorView(), Gravity.CENTER, 0, 0);}
通过设置Dialog的样式实现
public static void showShareWindow(Activity activity, View parentView, String pageName){
View mContentView = null;
V5ShareView mShareView = null;
if(mContentView == null){
mContentView = LayoutInflater.from(activity).inflate(R.layout.v5_share_layout, null);
}
if(mPopUpWindow == null){
mPopUpWindow = new PopupWindow(mContentView, LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT);
mPopUpWindow.setBackgroundDrawable(new BitmapDrawable());
mPopUpWindow.setOutsideTouchable(true);
mPopUpWindow.setFocusable(true);
}
if(mShareView == null){
mShareView = new V5ShareView(mContentView,pageName,activity);
}
mShareView.setOnShareViewDismiss(new ShareViewDismiss() {
@Override
public void dismiss() {
mPopUpWindow.dismiss();
}
});
mPopUpWindow.showAtLocation(activity.getWindow().getDecorView(), Gravity.CENTER, 0, 0);
}
希望可以帮到你。
参考资料
百度知道.百度知道[引用时间2018-1-26]
通过设置Dialog的样式实现
public static void showShareWindow(Activity activity, View parentView, String pageName){View mContentView = null;V5ShareView mShareView = null;if(mContentView == null){mContentView = LayoutInflater.from(activity).inflate(R.layout.v5_share_layout, null);}if(mPopUpWindow == null){mPopUpWindow = new PopupWindow(mContentView, LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT);mPopUpWindow.setBackgroundDrawable(new BitmapDrawable());mPopUpWindow.setOutsideTouchable(true);mPopUpWindow.setFocusable(true);}if(mShareView == null){mShareView = new V5ShareView(mContentView,pageName,activity);}mShareView.setOnShareViewDismiss(new ShareViewDismiss() {@Overridepublic void dismiss() {mPopUpWindow.dismiss();}});mPopUpWindow.showAtLocation(activity.getWindow().getDecorView(), Gravity.CENTER, 0, 0);}
希望可以帮到你。
梁兆铃