2014-10-07 61 views
0

我想显示网址栏和网页(在URL栏下方)。但我不知道为什么它只显示网页。为什么WebView中不显示地址栏?

XML代码:

<EditText 
    android:id="@+id/etURL" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 

    android:inputType="text"   
    /> 

<WebView 
    android:id="@+id/webview" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_below="@+id/etURL" 
/> 

Java代码

webView = (WebView) findViewById(R.id.webview); 
WebSettings ws = webView.getSettings(); 

ws.setJavaScriptEnabled(true); 
ws.setSupportMultipleWindows(true); 
ws.setSupportZoom(true); 
ws.setBuiltInZoomControls(true); 
ws.setCacheMode(WebSettings.LOAD_NO_CACHE); 
ws.setUseWideViewPort(true); 
ws.setLoadWithOverviewMode(true); 
ws.setLoadsImagesAutomatically(true); 
webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); 

webView.loadUrl(mURL); 
MyWebViewClient wvc = new MyWebViewClient(); 
webView.setWebViewClient(wvc); 
wvc.setActivity(this); 
wvc.setListener(this); 

我想,地址栏是由网页覆盖。如何在地址栏下方显示网页?

+0

如果我记得正确的是webclient相关的东西。尝试运行相同的没有'webView.setWebViewClient(wvc);' – Blackbelt 2014-10-07 12:51:42

+0

删除完整的'wvc'部分。但它没有运行@blackbelt – SGG 2014-10-07 12:58:58

+0

*没有运行什么*意思是 – Blackbelt 2014-10-07 12:59:37

回答

0
<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="com.example.networkex.WebViewActivity$PlaceholderFragment" > 

    <EditText 
     android:id="@+id/etURL" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:inputType="text" /> 

    <WebView 
     android:id="@+id/webView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@id/etURL"/> 

</RelativeLayout> 

这种组合对我很有帮助。试一试。

相关问题