Alexander
Alexander

Reputation: 171

How to show scroll bars in android's WebView

Is it possible to show scrollbars for scrollable html elements in android's WebView? How to do it?

Upvotes: 8

Views: 20847

Answers (4)

RandomType
RandomType

Reputation: 57

This works fine in your xml layout:

<WebView
    android:id="@+id/myWebView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbarThumbVertical="@color/primary_container_on_primary"
    android:scrollbarSize="2dp"/>

Upvotes: 2

Vivek Akkaldevi
Vivek Akkaldevi

Reputation: 9

WebSettings WebSettings12 = browser.getSettings();
WebSettings12.setBuiltInZoomControls(true);
webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webview.setScrollbarFadingEnabled(false);
webview.loadUrl("https://google.com");

Upvotes: 0

user1483208
user1483208

Reputation: 385

For me helped

android:scrollbarAlwaysDrawVerticalTrack="true"

Upvotes: -1

Houcine
Houcine

Reputation: 24181

in your onCreate() method : try this :

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.your_web_view_layout); 

    browser = (WebView)findViewById(R.id.your_webview);
    WebSettings mWebSettings = browser.getSettings();
    mWebSettings.setBuiltInZoomControls(true);
    browser.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    browser.setScrollbarFadingEnabled(false);
    browser.loadUrl("file:///android_asset/index.html");
}

Upvotes: 13

Related Questions