diff --git a/common/src/main/java/com/yunbao/common/dialog/OpenAdCenterDialogPopup.java b/common/src/main/java/com/yunbao/common/dialog/OpenAdCenterDialogPopup.java index 3f6211eea..046494ea8 100644 --- a/common/src/main/java/com/yunbao/common/dialog/OpenAdCenterDialogPopup.java +++ b/common/src/main/java/com/yunbao/common/dialog/OpenAdCenterDialogPopup.java @@ -4,6 +4,7 @@ import android.app.Activity; import android.content.Context; import android.graphics.Color; import android.util.Log; +import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; @@ -94,12 +95,12 @@ public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow { if (isShow) return; isShow = true; - int width = ScreenDimenUtil.getInstance().getScreenWdith() - DpUtil.dp2px(10); + int width = contentLayout.getWidth() - DpUtil.dp2px(20); int height = (int) (width * 1.5); if (model.getModel() == OpenAdModel.MODEL_SQUARE) { height = (int) (width * 1.2); } - Log.i("-----弹窗-----", "高度:" + height + " 宽度:" + width + " 布局宽度: " + contentLayout.getWidth() + " 屏幕宽度: " + ScreenDimenUtil.getInstance().getScreenWdith()); + Log.i("-----弹窗-----", "高度:" + height + " 宽度:" + width + " 屏幕宽度: " + ScreenDimenUtil.getInstance().getScreenWdith()); /*DebugDialog.getInstance(new DebugDialog.DebugDialogRunnable() { @Override public void run(DebugDialog dialog) { @@ -131,7 +132,9 @@ public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow { private void setWeb(OpenAdModel model, int width, int height) { WebView mWebView = new WebView(mContext); - mWebView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height)); + LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(width, height); + params.gravity = Gravity.CENTER; + mWebView.setLayoutParams(params); mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext((Activity) mContext, mWebView).setPageClose(true).setLiveZhuangBana(false), "androidObject"); mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 mWebView.getSettings().setJavaScriptEnabled(true); @@ -170,7 +173,10 @@ public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow { private void setImage(OpenAdModel model, int width, int height) { mImageView = new ImageView(mContext); mImageView.setScaleType(ImageView.ScaleType.CENTER_CROP); - mImageView.setLayoutParams(new LinearLayout.LayoutParams(width, height)); + LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(width, height); + params.gravity = Gravity.CENTER; + mImageView.setLayoutParams(params); + mImageView.setOnClickListener(v -> { if ("home_page_banner_battle".equals(model.getOriginalUrl())) { RouteUtil.forwardBattlePass(); diff --git a/common/src/main/res/layout/dialog_open_center_ad.xml b/common/src/main/res/layout/dialog_open_center_ad.xml index a67588370..8e078bb5d 100644 --- a/common/src/main/res/layout/dialog_open_center_ad.xml +++ b/common/src/main/res/layout/dialog_open_center_ad.xml @@ -10,8 +10,6 @@ android:id="@+id/content_layout" android:layout_width="0dp" android:layout_height="wrap_content" - android:layout_marginStart="20dp" - android:layout_marginEnd="20dp" android:layout_marginBottom="12dp" android:orientation="vertical" app:layout_constraintBottom_toBottomOf="parent"