-1
I’m trying to open an html inside the Assets in Android Studio, but the page is completely blank.
NOTE: When I put any external link, it works.
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(com.example.myapplication0.R.layout.activity_main)
val webView = findViewById<WebView>(com.example.myapplication0.R.id.webview)
val webSetting = webView.settings
webSetting.builtInZoomControls = true
webView.setWebViewClient(WebViewClient())
webView.loadUrl("assets/index.html")
}
}
This is my XML
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
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"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>