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