Is it possible to show scrollbars for scrollable html elements in android's WebView? How to do it?
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.
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.
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");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With