MainActivity.kt

// Compose <-> XML

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            DefaultTheme {
                // A surface container using the 'background' color from the theme
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colorScheme.background
                ) {
                    Greeting("Android")
                }
            }
        }
    }
}

@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {

    val progressValue = remember { mutableStateOf(0) }

    Column(
        modifier = Modifier.fillMaxSize(),
        horizontalAlignment = Alignment.CenterHorizontally,
        verticalArrangement = Arrangement.Center
    ) {

        AndroidView(
            factory = {context ->

                val view = LayoutInflater.from(context).inflate(R.layout.temp, null, false)

                view

            },
            update = { view ->

                val progressBar = view.findViewById<ProgressBar>(R.id.progressBar)
                progressBar.progress = progressValue.value

            },
            modifier = Modifier.fillMaxWidth()
        )
        
        Button(onClick = {
            progressValue.value += 10
        }) {
            Text(text = "UP")
        }

    }

}

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
    DefaultTheme {
        Greeting("Android")
    }
}