There's a webpage I pull up with webview, however i'd like to hide the 1 text link at the top. Is there a way to do this? The link is in the body, so I can't hide the body element in whole. The webpage is all text, and one tiny image at the bottom, but the text is generated each time you load it, so I can't just copy/paste the body.
Thanks
Alternatives to WebView If you want to send users to a mobile site, build a progressive web app (PWA). If you want to display third-party web content, send an intent to installed web browsers. If you want to avoid leaving your app to open the browser, or if you want to customize the browser's UI, use Custom Tabs.
How do I close WebView on Android? Add a close button and on its click set: webview. setVisibility(View. INVISIBLE); webview.
The Android system webview custom cache file has been deprecated and removed in Android 13. New apps and any app updates will now use the operating system default cache location.
final WebView webview = (WebView)findViewById(R.id.browser);
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url)
{
// hide element by class name
webview.loadUrl("javascript:(function() { " +
"document.getElementsByClassName('your_class_name')[0].style.display='none'; })()");
// hide element by id
webview.loadUrl("javascript:(function() { " +
"document.getElementById('your_id').style.display='none';})()");
}
});
webview.loadUrl(url);
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