How do disable and hide the address bar from a WebView?
Asked
Active
Viewed 6.0k times
49
-
7Please stop shouting. – Paul Sonier Nov 09 '10 at 17:05
-
1Edited. We can now take our hands off our hears... – Federico klez Culloca Nov 09 '10 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. – Cheryl Simon Nov 09 '10 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 – Jono Nov 10 '10 at 11:10
5 Answers
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()
.

CommonsWare
- 986,068
- 189
- 2,389
- 2,491
-
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 http://developer.android.com/reference/android/webkit/WebView.html – Jono Nov 09 '10 at 20:45
-
2@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. – CommonsWare Nov 09 '10 at 21:32
-
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. – Jay Mayu Jan 31 '11 at 17:36
-
1more info here on catching redirects http://stackoverflow.com/questions/8273991/webview-shouldinterceptrequest-example – giorgio79 Jan 17 '14 at 14:21
48
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
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.

King of Masses
- 18,405
- 4
- 60
- 77

SahanS
- 675
- 3
- 9
- 21
18
webview.setWebViewClient(new WebViewClient());
solved the problem for me..

Amnesh Goel
- 2,617
- 3
- 28
- 47

Mian Muhammad Umair Liaqat
- 221
- 2
- 7