修复三按键导航模式下,首页Banner进去可能网页底部显示不全的问题

This commit is contained in:
zlzw 2022-11-23 17:41:34 +08:00
parent d71fe7d92e
commit 08906e028a
3 changed files with 17 additions and 5 deletions

View File

@ -27,6 +27,7 @@ import com.yunbao.common.Constants;
import com.yunbao.common.R; import com.yunbao.common.R;
import com.yunbao.common.event.JavascriptInterfaceEvent; import com.yunbao.common.event.JavascriptInterfaceEvent;
import com.yunbao.common.utils.AndroidBug5497Workaround; import com.yunbao.common.utils.AndroidBug5497Workaround;
import com.yunbao.common.utils.DeviceUtils;
import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.JavascriptInterfaceUtils; import com.yunbao.common.utils.JavascriptInterfaceUtils;
import com.yunbao.common.utils.L; import com.yunbao.common.utils.L;
@ -67,14 +68,13 @@ public class WebViewActivity extends AbsActivity {
btnEdit = (ImageView) findViewById(R.id.btn_edit); btnEdit = (ImageView) findViewById(R.id.btn_edit);
ft_title = (FrameLayout) findViewById(R.id.ft_title); ft_title = (FrameLayout) findViewById(R.id.ft_title);
v_spacing = (View) findViewById(R.id.v_spacing); v_spacing = (View) findViewById(R.id.v_spacing);
mWebView = findViewById(R.id.webView);
AndroidBug5497Workaround.assistActivity(this); AndroidBug5497Workaround.assistActivity(this);
mWebView = new WebView(mContext);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
params.topMargin = DpUtil.dp2px(1); params.topMargin = DpUtil.dp2px(1);
mWebView.setLayoutParams(params); // mWebView.setLayoutParams(params);
mWebView.setOverScrollMode(View.OVER_SCROLL_NEVER); //mWebView.setOverScrollMode(View.OVER_SCROLL_NEVER);
rootView.addView(mWebView);
mWebView.setWebViewClient(new WebViewClient() { mWebView.setWebViewClient(new WebViewClient() {
@Override @Override
public boolean shouldOverrideUrlLoading(WebView view, String url) { public boolean shouldOverrideUrlLoading(WebView view, String url) {
@ -96,6 +96,9 @@ public class WebViewActivity extends AbsActivity {
if (url.contains("for")) { if (url.contains("for")) {
mWebView.loadUrl("javascript:goAnchorTab()"); mWebView.loadUrl("javascript:goAnchorTab()");
} }
//屏幕高度-ft_title的paddingTop
int height = DeviceUtils.getScreenHeight(mContext)-DpUtil.dp2px(24);
view.loadUrl("javascript:window.androidObject.setHeight("+height+",0)");
} }
}); });

View File

@ -484,7 +484,11 @@ public class JavascriptInterfaceUtils {
Handler handler = new Handler(Looper.getMainLooper()); Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> { handler.post(() -> {
ViewGroup.LayoutParams params = mWebView.getLayoutParams(); ViewGroup.LayoutParams params = mWebView.getLayoutParams();
params.height = DpUtil.dp2px(Integer.parseInt(height)); if("-1".equals(height)){
params.height=ViewGroup.LayoutParams.MATCH_PARENT;
}else {
params.height = Integer.parseInt(height);
}
mWebView.setLayoutParams(params); mWebView.setLayoutParams(params);
mWebView.setVisibility(View.VISIBLE); mWebView.setVisibility(View.VISIBLE);
}); });

View File

@ -63,4 +63,9 @@
android:layout_height="3dp" android:layout_height="3dp"
android:progressDrawable="@drawable/bg_horizontal_progressbar" android:progressDrawable="@drawable/bg_horizontal_progressbar"
android:visibility="gone" /> android:visibility="gone" />
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>