Issue
I'm new in Android Application. I am just wondering if there is a way to view a layout inside the webview? for example.
WebView webview = (WebView)findViewById(R.id.webView1);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setBuiltInZoomControls(true);
String url = "Layout location or R.Layout.test";
webview.loadUrl(url);
It's just like except of Using Activity class to View a layout like this setContentView(R.layout.test);
I'm trying to view the layout in a webview.
Any thoughts will be highly appreciated.
Solution
Whatever you saw in the tutorial, I presume they may not be loading layouts INTO the WebView
rather it may be along with
the WebView
.
In other words,you can actually use layouts similar to divs in a HTML.. you take a layout, add Webview into it and then add Buttons and other controls out side the webview tags as shown by lgw150.
This may give one the impression that the buttons etc are inside the webview but they are actually not! You can have something like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button android:id="@+id/button1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_weight="1"/>
<Button android:id="@+id/button2"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_weight="1" />
</LinearLayout>
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
For more check out this and this too.
Answered By - Nezam
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.