Vladimir
06/21/2024, 7:08 PM@Composable
fun QRScannerPreviewScreen() {
val lensFacing = CameraSelector.LENS_FACING_BACK
val context: Context = LocalContext.current
val lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current
val cameraController: LifecycleCameraController =
remember { LifecycleCameraController(context) }
cameraController.cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA
Scaffold(
floatingActionButton = {
FloatingActionButton(onClick = { }) {
Icon(Icons.Default.Add, contentDescription = "Add")
}
}
) { paddingValues: PaddingValues ->
Column(
) {
Box(modifier = Modifier.weight(1f)) {
AndroidView(
factory = {
PreviewView(it).apply {
this.controller = cameraController
cameraController.bindToLifecycle(lifecycleOwner)
}
},
modifier = Modifier.fillMaxSize().padding(paddingValues)
)
}
Box(modifier = Modifier.weight(1f)) {
Text("Other UI elements here", modifier = Modifier.padding(paddingValues))
}
}
}
}
Zach Klippenstein (he/him) [MOD]
06/22/2024, 12:20 AMVladimir
06/22/2024, 6:44 AMVladimir
06/22/2024, 6:55 AMVladimir
06/22/2024, 7:01 AMVladimir
06/22/2024, 7:30 AMAndroidView
will not clip its content to the layout bounds. Use View.setClipToOutline
on the child View to clip the contents, if desired. Developers will likely want to do this with all subclasses of SurfaceView to keep its contents contained.
I thusly have done the following:
AndroidView(
factory = {
PreviewView(it).apply {
this.controller = cameraController
cameraController.bindToLifecycle(lifecycleOwner)
clipToOutline = true
}
},
modifier = modifier
)
And it seems to have worked? I am not sure if this is the correct approach?Oliver.O
06/22/2024, 5:17 PMSorry, what do you mean? I am not used to utilizing Slack or its posting etiquette, I only use it to learn about KotlinLong content in a channel message means that navigating to the next message requires extra effort. Solution: Post only a small intro in the channel message, then send that, click on that message's 🧵 "Reply in thread" button, then post the long content in the thread message. Everyone is happy. It might even increase the chances of getting replies from people who know.
Vladimir
06/22/2024, 5:18 PM