Skip to content

Instantly share code, notes, and snippets.

@ruthwikkk
Created October 7, 2023 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruthwikkk/9b4ab8e1c70b66f8daddc5d1af95c536 to your computer and use it in GitHub Desktop.
Save ruthwikkk/9b4ab8e1c70b66f8daddc5d1af95c536 to your computer and use it in GitHub Desktop.
Add custom view to main layout
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Theme {
Surface(
modifier = Modifier.fillMaxSize(),
color = Color.Black
) {
val context = LocalContext.current
Box(
modifier = Modifier
.fillMaxSize()
) {
Image(
painter = painterResource(id = R.drawable.background),
contentDescription = "background",
contentScale = ContentScale.FillHeight
)
}
Box(
modifier = Modifier
.wrapContentSize()
.border(
width = 2.dp,
color = Color.Yellow
)
) {
AndroidView(
factory = {
BlurSurfaceView(context)
},
modifier = Modifier
.size(180.dp)
)
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment