1、布局文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent">
</WebView>
</RelativeLayout>
2、代码
package com.webview.demo;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.webkit.WebView;
public class MainActivity extends AppCompatActivity {
private WebView webView ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String webs = "\"<table style='font-size:12px;'><tr><td style='width:45px;'>" +
"起 息 日:</td><td>当日22:00前投资," +
"当日计息</td></tr><tr><td>还 款 日:</td><td>每日7点</td></tr><tr><td>还款方式:" +
"</td><td>按日付息</td></tr></table>\"" ;
webView = (WebView) findViewById( R.id.webview );
//webview
webView.loadDataWithBaseURL( null, webs , "text/html", "UTF-8", null ) ;
}
}
3、显示效果