Created
October 7, 2023 10:52
-
-
Save ruthwikkk/9b4ab8e1c70b66f8daddc5d1af95c536 to your computer and use it in GitHub Desktop.
Add custom view to main layout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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