50

How do disable and hide the address bar from a WebView?

4
  • 7
    Please stop shouting. Commented Nov 9, 2010 at 17:05
  • 1
    Edited. We can now take our hands off our hears... Commented Nov 9, 2010 at 17:09
  • The title was in all capital letters, this is annoying to a lot of users. As to the question, have you searched through the history? I'm pretty sure this has been answered before. Commented Nov 9, 2010 at 17:24
  • hi, i wasnt aware it was in caps. my mistake and yes i searched and could not find a solution. Now i have though thanks Commented Nov 10, 2010 at 11:10

5 Answers 5

64

There is no address bar in a WebView.

If you think you have a WebView, and you see an address bar, that is not your WebView. Rather, you are looking at the Browser application. Most likely, the URL you told the WebView to load did a redirect, and you did not intercept that redirect using a WebViewClient and shouldOverrideURLLoading().

Sign up to request clarification or add additional context in comments.

4 Comments

browser application? i did not call an intent to launch the browser application. i basically used a xml layout with just a single webview that fills the screen an i simple call LoaUrl to that webview. followed this example from the sdk developer.android.com/reference/android/webkit/WebView.html
@jonney: As I wrote, most likely, the URL you told the WebView to load did a redirect, and you did not intercept that redirect using a WebViewClient and shouldOverrideURLLoading(). A redirect or click on a link will load the resulting URL in the user's choice of browser, unless you use WebViewClient to change that behavior.
the address given in the android.com site is "google.com" when you go to google.com it redirects to google.lk :D datz why I see address bar.. Now I get it.. thanks a lot.
more info here on catching redirects stackoverflow.com/questions/8273991/…
49

Adding myView.setWebViewClient(new WebViewClient()); disabled the address bar for me.

import android.webkit.WebView;
import android.webkit.WebViewClient;

...

WebView myView = findViewById(R.id.myExampleView);
myView.setWebViewClient(new WebViewClient());
myView.getSettings().setJavaScriptEnabled(true);
myView.loadUrl("https://www.stackoverflow.com");

XML Snippet

<WebView android:id="@+id/myExampleView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:keepScreenOn="true"
    android:gravity="center" />

source: (Japanese site): http://www.techdoctranslator.com/android/webapps/webview

Comments

26

Finally I Try with this. Its worked for me..

Here is the working code

private WebView webview ;   
@Override

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ebook);

    //webview use to call own site
    webview =(WebView)findViewById(R.id.webView);

    webview.setWebViewClient(new WebViewClient());          
    webview .getSettings().setJavaScriptEnabled(true);
    webview .getSettings().setDomStorageEnabled(true);      
    webview.loadUrl("http://www.google.com"); 
}

and your entire main.xml(res/layout) look should like this:

<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    />

don't go to add layouts.

Comments

18
webview.setWebViewClient(new WebViewClient());  

solved the problem for me..

Comments

1

Kotlin code as following

myWebView.setWebViewClient(WebViewClient())

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.