lomza
lomza

Reputation: 9716

Hiding the scroll bar in WebView

I want to hide a vertical scroll bar in my WebView when I do not scroll the page. As for now, it is displayed always. I create a WebView programmatically, so my question is related to customization of the scroll bar programmatically. Thanks!

Upvotes: 29

Views: 46708

Answers (8)

Ian Mabuka
Ian Mabuka

Reputation: 11

This finally worked for me:

mWebView.setVerticalScrollBarEnabled(false);

Upvotes: 1

Sujeet Kumar
Sujeet Kumar

Reputation: 276

Try this -

For vertical scrollbar -

webView.setVerticalScrollBarEnabled(false) 

For Horizontal scrollbar -

webView.setHorizontalScrollBarEnabled(false);

Upvotes: 3

Vettiyanakan
Vettiyanakan

Reputation: 8470

No need to change your Java code.
It will work if you put android:scrollbars="none" in your XML.

<WebView
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:scrollbars="none" />

Upvotes: 49

user2160194
user2160194

Reputation:

Set scrollbars to none in the XML for WebView. For reference try this code.

<WebView android:id="@+id/webView"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:scrollbars="none"/> 

Upvotes: 14

Sergey Glotov
Sergey Glotov

Reputation: 20346

setScrollbarFadingEnabled() method does exactly what you want. It hides scrollbar when the view isn't scrolling.

webView.setScrollbarFadingEnabled(true);

Upvotes: 16

Pijusn
Pijusn

Reputation: 11293

Similar to other answers but to get a scrollbar that behaves like the one in ListView, this is the code:

webView.setScrollbarFadingEnabled(true); // Explicitly, however it's a default, I think.
webView.setScrollBarStyle(WebView.SCROLLBARS_INSIDE_OVERLAY);

Upvotes: 1

worked
worked

Reputation: 5880

This is what you are after:

mWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);

Upvotes: 8

ilango j
ilango j

Reputation: 6037

try this code,

webView.setVerticalScrollBarEnabled(false);

Upvotes: 65

Related Questions