Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 653
Alexander Avatar asked Oct 29 '11 10:10

Alexander


People also ask

How do I disable scrolling in WebView?

If you put a WebView in a ScrollView, set the android:isScrollContainer attribute of the WebView to "false" rather than setting android:scrollbars to "none". This has the effect of completely disabling the scroll handling of the webview and allows it to expand according to its content.

How do I make WebView scrollable in react native?

Simple Example return ( <SafeAreaView style={{flex: 1}}> <ScrollView style={{ width: '100%' }} contentContainerStyle={{ flexGrow: 1 }} > <WebView source={{ uri: contentUrl }} originWhitelist={['*']} /> </ScrollView> </SafeAreaView> ); {flex: 1} and { width: '100%' } are important otherwise content will not be visible.


1 Answers

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");
}
like image 52
Houcine Avatar answered Nov 15 '22 01:11

Houcine