How to hide scrollbars in WebView

How to hide scrollbars on Android

This is a post after a long time. Recently, Android application development has progressed smoothly, and I have gained a general knowledge, so I would like to post a summary.

I'm currently making an information app for students, and I used WebView, which loads a website into the app and displays it.

At that time, there was an incident in which the scroll bar was not displayed in a certain news app, but the vertical and horizontal scroll bars were displayed in the one I made, so I will post how to hide it.

main.xml


<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <WebView
        android:id="@+id/webview_id"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </WebView>

</FrameLayout>

I will make it possible to display WebView in xml.

MainActivity.java


public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //Add WebView installed in layout
        WebView webView = findViewById(R.id.webview_id);
        //Enable JavaScript
        webView.getSettings().setJavaScriptEnabled(true);

        //Hide vertical and horizontal scrollbars
        webView.setVerticalScrollBarEnabled(false);
        webView.setHorizontalFadingEdgeEnabled(false);

        //Displayed in WebView without transitioning to the standard browser when clicking the link.
        webView.setWebViewClient(new WebViewClinet());
        //In "loadUrl", describe the URL you want to display (Chrome is displayed here)
        webView.loadUrl("https://www.google.com");
    }
}
webView.setVerticalScrollBarEnabled(false);
webView.setHorizontalFadingEdgeEnabled(false);

Simply put, you can remove the scrollbar just by adding these two lines. I would like to post a way to open another Activity and jump to the link when I have time.

I've only touched it for a month, but I've gained a lot of knowledge ... I would like to increase the posting frequency.

Recommended Posts

How to hide scrollbars in WebView
How to hide null fields in response in Java
How to hide args4j default
How to use Lombok in Spring
How to run JUnit in Eclipse
How to iterate infinitely in Ruby
[Rails] How to write in Japanese
How to run Ant in Gradle
How to master programming in 3 months
How to learn JAVA in 7 days
How to get parameters in Spark
How to install Bootstrap in Ruby
How to use InjectorHolder in OpenAM
How to introduce jQuery in Rails 6
How to use classes in Java?
How to name variables in Java
How to set Lombok in Eclipse
How to concatenate strings in java
How to install Swiper in Rails
[swift5] How to specify color in hexadecimal
How to implement search functionality in Rails
How to implement Kalman filter in Java
How to change app name in rails
How to get date data in Ruby
How to use custom helpers in rails
How to reflect seeds.rb in production environment
How to use named volume in docker-compose.yml
How to filter JUnit Test in Gradle
How to insert a video in Rails
How to standardize header footer in Thymeleaf
How to include Spring Tool in Eclipse 4.6.3?
How to add jar file in ScalaIDE
How to do base conversion in Java
[Swift] How to fix Label in UIPickerView
How to have params in link_to method
How to use Docker in VSCode DevContainer
How to use MySQL in Rails tutorial
How to fix system date in JUnit
How to implement coding conventions in Java
How to embed Janus Graph in Java
[rails] How to configure routing in resources
How to map tsrange type in Hibernate
How to get the date in java
How to implement ranking functionality in Rails
How to use environment variables in RubyOnRails
How to implement asynchronous processing in Outsystems
How to publish a library in jCenter
How to specify id attribute in JSF
Understand in 5 minutes !! How to use Docker
How to overwrite Firebase data in Swift
How to use credentials.yml.enc introduced in Rails 5.2
How to assemble JSON directly in Jackson
How to execute multiple commands in docker-compose.yml
[For beginners] How to debug in Eclipse
How to use ExpandableListView in Android Studio
How to display error messages in Japanese
How to deploy
Summary of how to select elements in Selenium
How to get keycloak credentials in interceptor class
[JavaFX] How to write Eclipse permissions in build.gradle
(Memo) How to solve dummy output in Ubuntu 20.04