Constraint layout is by far one of the most versatile ViewGroups in the Android framework, However, the Kotlin code needed to update the constraints of a view programmatically can be a bit wordy. I have created a Constraint Layout Kotlin Extension that will make that process much easier to apply and cleaner to look at in code. Let’s get started!

Constraint Instructions

Here we have the ConstraintInstructions interface that has two simple implementations, ConnectConstraint and DisconnectConstraint.

ConnectConstraints takes 4 parameters that help describe the view you're looking to constrain and to what.


I completed a project that used LiveData to emit data to my views from my ViewModel. In this article, I will review the tests I wrote for my ViewModel in hopes that this information will be useful to someone out there in the Android World.

My ViewModel

This is the entire ExhangeRateViewModel class and I’ll walk through some of its parts to explain the logic.

I used Dagger to inject my BaseRepository implementation into the ExchangeRateViewModel. …

Eric Diaz

Junior Android Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store