2013-02-01 69 views
2

我是Android应用程序中的新手。我只是想知道是否有一种方法来查看webview内的布局?例如。在Webview中查看Android布局

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); 

这就像除了使用Activity类查看这样 的setContentView(R.layout.test)布局的;

我试图在webview中查看布局。

任何想法将不胜感激。

+0

网页视图用于加载网址,而不是布局。其定义。 – Niko

+1

你想做什么?您可能会对此类问题产生负面声誉 – Niko

+0

如果可能,我试图将一个布局加载到WebView中。 –

回答

0

无论您在本教程中所看到的,我相信他们可能没有加载布局INTOWebView有时反而是along withWebView

换句话说,您实际上可以使用与HTML中的div相似的布局..您可以采用布局,将Webview添加到布局中,然后将按钮和其他控件添加到webview标记的旁边,如lgw150所示。

这可能会给人一种印象,按钮等是在web视图内,但他们实际上不是! 你可以有这样的事情:

<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"/> 

现在在刻度更检查出thisthis too。点击我的答案左侧。

0

查看网页视图内的布局?我不明白清楚了,下面也许是你

<ProgressBar 
android:id="@+id/progWeb" 
style="@style/progressbar" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:background="@android:color/darker_gray" 
android:max="100" 
android:visibility="invisible" /> 

<WebView 
android:id="@+id/web" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:layout_alignParentLeft="true" 
android:layout_below="@+id/progWeb" 
android:layout_marginTop="28dp" />