0
我想在Android应用程序中同时显示2个WebViews。我想知道这是否可能,因为我还没有遇到过这样的应用程序。如果有什么方法可以告诉我如何去做?显示多个网页浏览
我想在Android应用程序中同时显示2个WebViews。我想知道这是否可能,因为我还没有遇到过这样的应用程序。如果有什么方法可以告诉我如何去做?显示多个网页浏览
make you xml like below
<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"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="2" >
<WebView
android:id="@+id/web1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<WebView
android:id="@+id/web2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</RelativeLayout>
write you activity below code
WebView webView1 = (WebView)findViewById(R.id.web1);
WebView webView2 = (WebView)findViewById(R.id.web2);
WebSettings settings1 = webView1.getSettings();
WebSettings settings2 = webView2.getSettings();
settings1.setJavaScriptEnabled(true);
settings2.setJavaScriptEnabled(true);
webView1.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webView1.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webView1.loadUrl("www.google.co.in");
webView2.loadUrl("http://stackoverflow.com/");