Android 如何在活动中嵌入webview以显示html片段?
全部。有人能给我一些关于如何将webview添加到活动视图层次结构并让它显示html的线索或说明吗?在布局文件夹中创建xmlAndroid 如何在活动中嵌入webview以显示html片段?,android,webview,Android,Webview,全部。有人能给我一些关于如何将webview添加到活动视图层次结构并让它显示html的线索或说明吗?在布局文件夹中创建xml <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_w
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white">
<WebView android:id="@+id/wv1"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:background="@color/white" />
<WebView android:id="@+id/wv2"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:background="@color/white"/>
</FrameLayout>
在res文件夹中创建一个XML文件,在res文件夹中声明您的WebView
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@color/white">
<WebView android:id="@+id/web" android:layout_height="fill_parent"
android:layout_width="fill_parent" android:background="@color/white" />
</FrameLayout>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@color/white">
<WebView android:id="@+id/web" android:layout_height="fill_parent"
android:layout_width="fill_parent" android:background="@color/white" />
</FrameLayout>
WebView wv1 = (WebView)findViewById(R.id.web);
wv1.loadDataWithBaseURL(null, "HTML String", mimeType, encoding, null);