package com.itant.htmltest;

import android.os.Build;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        WebView wv_warning = (WebView) findViewById(R.id.wv_warning);
        WebSettings settings = wv_warning.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setBuiltInZoomControls(false);
        // 设置显示完整网页
        settings.setUseWideViewPort(true);
        settings.setLoadWithOverviewMode(true);
        settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
        wv_warning.setBackgroundColor(0x00000000);
        /*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
        }*/

        wv_warning.loadData("<h2 style=\"text-align:left;\">\n" +
                "\t发大发发<img src=\"http://42.51.148.164/web/kindeditor/attached/image/20161013/20161013201109_8063.jpg\" alt=\"\" />\n" +
                "</h2>\n" +
                "<br />\n" +
                "<p>\n" +
                "\t<br />\n" +
                "</p>", "text/html; charset=UTF-8", null);
    }
}
