Showing Views in a Compose app
Imagine you have written a View-based custom component for one of your previous apps—for example, an image picker, a color chooser, or a camera preview—or you would like to include a third-party library such as Zebra Crossing (ZXing) to scan Quick Response (QR) codes and barcodes. To incorporate them into a Compose app, you need to add the View (or the root of a View hierarchy) to your composable functions. Let’s see how this works.
Adding custom components to a Compose app
The ZxingDemo example, shown in the following screenshot, uses the ZXing Android Embedded barcode scanner library for Android, which is based on the ZXing decoder. It is released under the terms of the Apache-2.0 License and is hosted on GitHub (https://github.com/journeyapps/zxing-android-embedded):
Figure 9.1 – The ZxingDemo example app
My example continuously scans for barcodes and QR codes. The decorated barcode view...