Custom Views in Android Kotlin
Custom views is one of the most crucial concept one should know as an Android Developer. We have many pre-defined built-in views in Android Framework such as TextView, EditText, Button, but if we want to create our own custom views we can also do that. Let’s first understand what are custom views,
Custom Views are the user interface that the user’s create by extending one of the the pre-existing views according to the specific needs.
In this article, we will understand how to build a Horizontal Custom Text view. I picked this horizontal custom view as this is easy to implement and understand. One of the advantages of creating a custom view is that if we have to use this in many places throughout the project then in each and every place we don’t have to write the whole layout code.
Now let’s deep dive and design Horizontal custom TextView,
First we will create an Android Project in Android Studio using the empty view Activity. It will be better if you implement view binding, for this you go to the build.gradle inside the Gradle Scripts and set viewBinding and dataBinding as true and add the kotlin Kapt plugin.
Now we will create layout for our Horizontal Custom TextView. In this custom text view, we have have an ImageView and two TextViews placed horizontally.