Building adaptive layouts using ConstraintLayouts
Jetpack Compose, a declarative UI toolkit to build great UIs, is ideal to implement and design screen layouts that adjust automatically by themselves and render content well across different screen sizes.
This can be useful to consider when building your application, since the chance of it being installed in a foldable device is high. Furthermore, this can range from simple layout adjustments to filling up a foldable space that looks like a tablet.
Getting ready
You need to have read the previous chapters to follow along with this recipe.
How to do it…
For this recipe, we will build a separate composable function to show you how to use ConstraintLayout
in the same project instead of creating a new one:
- Let’s go ahead and open
Traveller
. Add a new package and call itconstraintllayoutexample
. Inside the package, create a Kotlin file, calledConstraintLayoutExample
, and then add the following dependency...