webView 显示一段 html 代码
生活随笔
收集整理的這篇文章主要介紹了
webView 显示一段 html 代码
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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"><WebViewandroid: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 ;@Overrideprotected 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 );//webviewwebView.loadDataWithBaseURL( null, webs , "text/html", "UTF-8", null ) ;} }?
3、顯示效果
總結
以上是生活随笔為你收集整理的webView 显示一段 html 代码的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: TextView显示颜色高亮的问题
- 下一篇: 【转载】安卓APP架构