Shivam Sethi
03/21/2021, 8:08 PMmatch_parent
for height and width not sure how can achieve that here, it just put black screen top and bottom but preview size remains the same if I do Modifier.fillmaxSize()
jaqxues
03/21/2021, 8:36 PMShivam Sethi
03/21/2021, 8:43 PMShivam Sethi
03/21/2021, 8:44 PMLinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)
but no effectjaqxues
03/21/2021, 9:05 PMjaqxues
03/21/2021, 9:06 PMShivam Sethi
03/21/2021, 9:09 PMxml PeviewView
Shivam Sethi
03/21/2021, 9:09 PMprivate fun startCamera() {
val cameraProviderFuture = ProcessCameraProvider.getInstance(this)
cameraProviderFuture.addListener({
// Used to bind the lifecycle of cameras to the lifecycle owner
val cameraProvider: ProcessCameraProvider = cameraProviderFuture.get()
// Preview
val preview = Preview.Builder()
.build()
.also {
it.setSurfaceProvider(previewView.surfaceProvider)
}
// Select back camera as a default
val cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA
try {
// Unbind use cases before rebinding
cameraProvider.unbindAll()
// Bind use cases to camera
cameraProvider.bindToLifecycle(
this, cameraSelector, preview
)
} catch (exc: Exception) {
Log.e(DEBUG_TAG, "Use case binding failed", exc)
}
}, ContextCompat.getMainExecutor(this))
}
Neal Sanche
03/22/2021, 3:14 AMpreviewView.implementationMode = PreviewView.ImplementationMode.COMPATIBLE
which seems to be more stable for me. I've put in a bug report for a similar problem: https://issuetracker.google.com/issues/179291080Neal Sanche
03/22/2021, 3:18 AMNeal Sanche
03/22/2021, 3:19 AMCyril Find
03/22/2021, 7:45 AMCyril Find
03/22/2021, 7:46 AMpreviewView.implementationMode = PreviewView.ImplementationMode.COMPATIBLE
fixed it
(i don't remember why i didn't use the update
lambda in the end 😅)Neal Sanche
03/22/2021, 4:12 PMupdate
lambda didn't exist. But, it's also going to restart the camera use cases, which might not be what you want.Shivam Sethi
03/22/2021, 7:08 PM