webview内容(高度)适合在Android上是错误的

时间:2019-03-16 15:12:17

标签: android webview

我正在尝试使WebView仅用于研究,但是某些网页的高度与其他网页相比是小/大。见图1和2 谁能教我如何使所有WebView的高度相同。

我尝试通过设置一些选项来设置固定高度,但是不起作用。

webview source
myWebview.setInitialScale(1);
myWebview.getSettings().setJavaScriptEnabled(true);
myWebview.getSettings().setLoadWithOverviewMode(true);
myWebview.getSettings().setUseWideViewPort(true);
myWebview.getSettings().setSupportZoom(true);
myWebview.getSettings().setBuiltInZoomControls(false);
myWebview.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
myWebview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
myWebview.getSettings().setDomStorageEnabled(true);
myWebview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
myWebview.setScrollbarFadingEnabled(true);
myWebview.getSettings().setUseWideViewPort(true);
myWebview.getSettings().setLoadWithOverviewMode(true);
myWebview.setLayerType(View.LAYER_TYPE_HARDWARE, null);
myWebview.getSettings().setJavaScriptEnabled(false);
myWebview.setScrollBarSize(WebView.SCROLLBARS_INSIDE_OVERLAY);
myWebview.getSettings().setSupportZoom( true ); //Modify this
myWebview.setInitialScale(1);

布局

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <WebView
        android:id="@+id/webview2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        tools:layout_editor_absoluteX="8dp"
        tools:layout_editor_absoluteY="8dp" />

</android.support.constraint.ConstraintLayout>

m.nate.com

enter image description here

m.daum.net

enter image description here

0 个答案:

没有答案
相关问题