What will this article be about?!
Something new that I started learning a few days ago. If you know my work, you know I prefer to work in the front-end field. I first design the element and then create it in XML. (So it has been so far). But Jetpack Compose is something different, something very different that takes a lot of time to learn because it’s completely XML-free in design.
I admit such big changes scare me because I think about how long it will take to learn this. But if I learn regularly, I will succeed more and more, so I will get to the level of designing custom elements like I used to in XML.
You will need a newer version of Android Studio. You can download it from here. I am not making a video and tutorial on how to install it because a lot of videos are available on YouTube. I am going to create these code snippets in a new project, so follow this article if you don’t want to miss out on updates and novelties. Or sign up for my newsletter to be the first to know about the news.
The first step
is to create a new project by selecting “Empty Compose Activity”. I also attached a photo of you so you can do this. 👇
The second step
is to add the following implementations. You can add this to the “build.gradle” file.
implementation "androidx.compose.foundation:foundation:$compose_version" implementation "androidx.compose.runtime:runtime-livedata:$compose_version" implementation "androidx.compose.runtime:runtime-rxjava2:$compose_version" implementation "androidx.compose.material:material-icons-core:$compose_version" implementation "androidx.compose.material:material-icons-extended:$compose_version"
Additional values, such as sizes, colors, texts, or icons, can be found in the “dimens.xml”, “colors.xml”, “string.xml”, and “drawable” file/ folder. (I did not paste this here, but the full code will be available at the end of the article from where you can access it.) I always organize the elements in a separate folder so that I can easily modify them later and it be transparent when working on larger projects. So I created a folder called “uigitdev” in which I will store these elements.
In summary, I like this new thing. I also started learning because it seems useful. Based on my previous works, this is a completely different structure, so it will be a little harder to switch, but with a lot of practice, I will soon catch up myself and I am going to make new beautiful elements.