Using of ConstraintLayout to support different Android screen sizes with Material Design Martin Baraya Follow Jan 21 · 1 min read

What is Constraint Layout?

ConstraintLayout allows you to create large and complex layouts with a flat view hierarchy and that means there are no nested view groups.



Constraint Layout == Relative Layout and it is an improved Relative Layout.

Tip: Always use Constraint Layout for creating Complex layouts.

So, let’s start building the ConstraintLayout example project with the source code

NOTE In this example, I use Android Studio 3.3

AndroidManifest.xml

MainActivity.kt

Add the following file to the res/drawable/

header.xml

Inside the layout folder we have the following:

activity_main.xml

Inside the values folder we have the following:

colors.xml

strings.xml

styles.xml

For Gradle build tool

Gradle Top-level

NOTE In this example, I use AndroidX (you can check out the tutorial video)

Gradle app level

If you are looking to developing Android Apps by using modern architecture components (MVVM)

I have a Masterclass course with over 5,000 students, enrollment about Android Jetpack with Kotlin, you can use this coupon Link → Check here