Photo by Diego PH on Unsplash

I have faced a task in Jetpack Compose project recently. I had to create a linear progress bar with gradient.


Photo by Andreas Dress on Unsplash

Row

A Row is a layout used to display child components in a horizontal manner.

If you wished to display three texts a row you can create a Row like below:

Row() {
Text("Text1", Modifier.background(Color.Cyan), fontSize = 24.sp)
Text("Text2", Modifier.background(Color.Gray), fontSize = 24.sp)
Text("Text3", Modifier.background(Color.Blue), fontSize = 24.sp)
}


A merge adapter has been introduced recently and you can implement it in your project now. However, I’d also like to point out that a lot of people have some doubts in using it. I’ll show you in this article difference between a new approach of implementation elements with different types (Merge Adapter) and an old approach (Multi ViewHolders).

Photo by Ingmar H on Unsplash

For using MergeAdapter you should add implementation “androidx.recyclerview:recyclerview:1.2.0-alpha02” in build.gradle. You can get the last version here.


Overview
This is the article about Data Binding. After learning of this article you manage to assume that you have studied Data Binding.
Undoubtedly if you didn’t face with Data Binding later, you should read my previous parts about Data Binding. It doesn’t take plenty of time.

Photo by Daniel Sebnar on Unsplash

Continuation

You will have a lot situations, when you data is changeable. Data updating can occur on the server or in another storage and you will need to show new data. Consider the simple example.

MainActivity.kt

class MainActivity : AppCompatActivity() {

private lateinit var binding: ActivityMainBinding
private var…


Photo by Sajad Nori on Unsplash

Continuation
I have showed basis features in the previous part. In this article I’ll show the main features of Data Binding.
Undoubtedly if you didn’t face with Data Binding later, you should read my previous part about Data Binding. It doesn’t take plenty of time.
Code in layout
You will have a lot of cases when you need to set a field with not type String.

data class Person(
var id: Long,
var name: String,
var surname: String,
var salary: Int
)

You can solve this problem throw Data Binding in the xml file. …


Overview
The Data Binding Library is a support library that allows you bind UI components in your layouts to data sources in your app using a declarative format rather than programmatically.
The Data Binding Library offers both flexibility and broad compatibility — it’s a support library, so you can use it with devices running Android 4.0 (API level 14) or higher.

Photo by Annie Spratt on Unsplash

Get started
At the beginning you should enable data binding in build.gradle file.

Want to read this story later? Save it in Journal.

dataBinding {
enabled true
}

Farther you should add <layout> tag in your xml file.

<?xml…

Andrey Molochko

Hey, I'm Andrey. I'm an Android Developer from Belarus. Also I create applications via Flutter. I thirdly believe, that my articles will be useful for you.

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