Compose WebView Part 1 Load URL

WebView With Jetpack Compose in Android Studio | Kotlin | Jetpack Compose | Android Tutorials

In Android, a Compose WebView is an extension of View Class that allows us to display webpages. In simpler words, if you want to display a webpage in Activity Layout, then you can implement a WebView to display it. 

Add INTERNET permission in the AndroidManifest.xml file

Navigate to the AndroidManifest.xml file and add INTERNET permission as shown below.

  <!-- Add this permission -->
<uses-permission android:name="android.permission.INTERNET"/>


Working with the MainActivity.kt file

Go to the MainActivity.kt file and refer to the following code. Below is the code for the MainActivity.kt file. Comments are added inside the code to understand the code in more detail.

package com.blogspot.boltuix

import android.os.Bundle
import android.view.ViewGroup
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.runtime.Composable
import androidx.compose.ui.viewinterop.AndroidView

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        setContent {

fun WebViewPage(url: String){
    // Adding a WebView inside AndroidView
    // with layout as full screen
    AndroidView(factory = {
        WebView(it).apply {
            layoutParams = ViewGroup.LayoutParams(
            webViewClient = WebViewClient()
    }, update = {



Android: Cleartext HTTP traffic not permitted Android 9

Starting with Android 9.0 (API level 28), cleartext support is disabled by default.

AndroidManifest.xml -

<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
    <uses-permission android:name="android.permission.INTERNET" />

GET source code on Github: