私はConstraintsとwebViewとloadDataを使用しようとしていましたが、得られたものはすべて白い画面でした。私がLinearLayoutに変更したとき、それはうまくいった。今、Constraintの中のLinearLayoutを試してみると、白い画面が表示されます。 Constraintsでこの作業を行うためのソリューションはありますか?ありがとうございます; ;AndroidのConstraintsレイアウトで白い画面を表示するWebViewとloadData
MainActivity
package com.example.grady.webviewdemo;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.webkit.WebView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView mWebView = (WebView) findViewById(R.id.myWebView);
String myHtmlString = "<html> <head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></head><body>" +
"<h2>This is a HTML Heading in Android WebView.</h2>\n" +
"<p>This is a HTML paragraph in android WebView.</p>\n" +
"\n" +
"<h4>Following is HTML Table in WebView</h4>\n" +
"<table border=\"1\" width=\"100%\">\n" +
" <tr>\n" +
" <td>Android</td>\n" +
" <td>WebView</td>\t\t\n" +
" <td>100</td>\n" +
" </tr>\n" +
" <tr>\n" +
" <td>Android</td>\n" +
" <td>WebView</td>\t\t\n" +
" <td>200</td>\n" +
" </tr>\n" +
" <tr>\n" +
" <td>Android</td>\n" +
" <td>WebView</td>\t\t\n" +
" <td>300</td>\n" +
" </tr>\n" +
"</table>" +
"</body></html>";
mWebView.loadData(myHtmlString, "text/html; charset=UTF-8", null);
}
}
activity_main.xml
<?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="com.example.grady.webviewdemo.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:id="@+id/myWebView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
私はあなたが提供されたコードサンプルを実行してきましたしかし、あなたはこれを試すことができます。私のために、そこにテーブルがあるWebviewが表示されています。 – CodeCameo