当前使用的腾讯的x5的
原布局
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:id="@+id/ll_web_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.uama.weight.uama_webview.BridgeWebView
android:id="@+id/community_detail_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible" />
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
在java代码中需要将原来的布局移除,重新new一个webview在添加进去,就能解决WebView底部空白问题
ll_web_view
是上述xml代码中的LinearLayout
ll_web_view.removeViewAt(0);
BridgeWebView bridgeWebView = new BridgeWebView(CommunityDetailActivity.this);
bridgeWebView.setBackgroundColor(Color.GRAY);
WebViewTemplateUtils.loadTemplate(CommunityDetailActivity.this, bridgeWebView, info);
ll_web_view.addView(bridgeWebView, 0,
new LinearLayout.LayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)));