<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Aiman Nabeel on Medium]]></title>
        <description><![CDATA[Stories by Aiman Nabeel on Medium]]></description>
        <link>https://medium.com/@aimnab?source=rss-a39749345621------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*5q00bqMSHIiJqU_2vQlaJQ.jpeg</url>
            <title>Stories by Aiman Nabeel on Medium</title>
            <link>https://medium.com/@aimnab?source=rss-a39749345621------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 22:39:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aimnab/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[To Compose, or Not to Compose, That is the Question]]></title>
            <link>https://medium.com/better-programming/to-compose-or-not-to-compose-that-is-the-question-fa616c270b5?source=rss-a39749345621------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa616c270b5</guid>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Aiman Nabeel]]></dc:creator>
            <pubDate>Mon, 25 Apr 2022 12:10:18 GMT</pubDate>
            <atom:updated>2022-05-25T11:17:26.258Z</atom:updated>
            <content:encoded><![CDATA[<h4>Android View System vs Jetpack Compose — <em>A quick comparison when creating animations</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*H2YBrsAmXNm4tsXT4xWRxA.jpeg" /></figure><p>With the release of another stable version of Jetpack Compose (woohoo! 🎉) back in February, we need to take a moment to appreciate the immense hard work and determination by the engineering team at <a href="https://medium.com/u/be36e94a7e47">Google</a>. They have been taking feedback from the world-wide Android community and continuously improving this UI toolkit for us. Exciting times!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5hfAu8MUlBjf21CqE52YJw.png" /></figure><p>I have been following the development of Jetpack Compose libraries and playing around with it even when very few of us may not have been ready to take it seriously.</p><p>Me 👶:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*IB_h9XWgC-qyVdYc" /></figure><p>Team:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*A7vqrVIH7Z8iT3mF" /></figure><p>There’s much to say about Compose and how much it has evolved in just a couple of years. So I decided to share some of my thoughts on playing around with it, starting with this one as my first ever technical blog (me: no pressure! 👼).</p><p>To begin with, I thought I’d share a specific use case that was raised and discussed with my team. We had planned to add an animated search bar in the app and the discussion went on something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/0*ji1q3ckSuL6qL34P" /></figure><p>What concerned me with developing it with the existing Android view system was the duplication of code that needs to be done on the related XML files to make the animation work (explained below). Surely, there must be a better way to do it. Which led to this million dollar question:</p><blockquote><em>To compose or not to compose?</em></blockquote><p>Too dramatic? To test this scandalous theory that I had now announced, this is what I did next. Similar to what we have in the app, I decided to create an<strong><em> </em></strong>animated search bar using both technologies.</p><p>I created two projects, one with the Android view system and the other with Jetpack Compose (both available on GitHub and linked as follows). Here’s what it looks like with the Android view system:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*H9uXkPsVL9K-FGX-" /><figcaption>GitHub: <a href="https://github.com/Aimannab/SearchApp">https://github.com/Aimannab/SearchApp</a></figcaption></figure><p>Let’s see for example, in my SearchApp project, I’m creating an <strong>ImageButton</strong> for the back arrow:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bd9e88fb934e4027e318bbb0b94eb765/href">https://medium.com/media/bd9e88fb934e4027e318bbb0b94eb765/href</a></iframe><p>See how we need to duplicate <strong>search_header_back_arrow</strong> twice in the <strong>search_header_motion_scene.xml</strong>. We know we will have to do the same for other elements that would be part of the animation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb03a445af2cb418983644524bbc97da/href">https://medium.com/media/eb03a445af2cb418983644524bbc97da/href</a></iframe><p>For me, this is not ideal and it has always bothered me. When I looked into how we can do the same thing in Compose, I was not disappointed!</p><p>So, how did I create the same transition in Compose? I used <a href="https://developer.android.com/jetpack/compose/animation"><strong>AnimatedVisibility</strong></a> for the back button in the ComposableSearchApp project as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/233784da4a3b064520c3167258381eb8/href">https://medium.com/media/233784da4a3b064520c3167258381eb8/href</a></iframe><p>Where the back button widget is created once and can be reused as many times as you’d want. Here’s what it looks like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/18597e8cbb051506e34c86df593a7b6f/href">https://medium.com/media/18597e8cbb051506e34c86df593a7b6f/href</a></iframe><p>The search bar state is also handled programmatically using <strong>enum</strong> values giving us more flexibility with tweaking the animation as we like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f3d7d749933711fc14be48038b2b2f45/href">https://medium.com/media/f3d7d749933711fc14be48038b2b2f45/href</a></iframe><p>And that’s it! 🙌</p><p>So, what benefits did I see with Jetpack Compose?</p><p>✅ <strong>Cleaner code</strong>: The code is way cleaner, shorter and well-structured. If I want to make changes in the SetupBackButton widget, I only make it once. As opposed to what we used to do with XML, where we had to make the same change everywhere the back button was created/set up (<strong>main_activity.xml</strong> + start transition + end transition).</p><p>✅ <strong>Faster compilation</strong>: The code is quicker to execute with the <a href="https://developer.android.com/jetpack/compose/tooling"><strong>@Preview</strong> </a>annotation to your connected device or emulator. The preview gets deployed within the same project app as a new activity, so it shares the same context and permissions, which means we don’t have to write boilerplate code e.g. asking for a permission if it has already been granted.</p><p>✅ <strong>Reusability</strong>: The biggest benefit that sells itself here is reusability and faster development. The SetupBackButton widget can be reused as many times in the project as we want with its own custom animation. This means, you only write/create the widgets once and apply different versions of that same animation in different locations across your app.</p><p>💡<strong>Experimental</strong>: The only thing that I’d keep in mind is that <strong>AnimatedVisibility</strong> is still at the experimental stage, which means it may be subject to changes or getting removed.</p><p>💡<strong>Interactive Mode</strong>: I’m hoping that playing around with animations will be extended in the future, although we do have a basic tool i.e.<strong>Start Interactive Mode</strong>. This lets you preview and test gestures without building the whole project every time. It comes with limitations like no network access, no file access and some Context APIs may not be fully available.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*44eH4G5Pd-kmL5cbGR6Lmg.png" /></figure><p>*******************************************************************</p><p><strong>UPDATE (May 2022):</strong></p><p>Checkout new <a href="https://developer.android.com/studio/preview/features#new_in_compose">tooling support</a> with Compose 1.2 Beta announced at Google I/O 2022:</p><blockquote><strong>Animation Preview</strong>: If your animations are described in a composable preview, you can now use <a href="https://developer.android.com/jetpack/compose/tooling#animations">Animation Preview</a> to inspect and coordinate all of them at once. You can also freeze a specific animation.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*2lLVGkmjmkuLetdEW0uARQ.gif" /></figure><p>*******************************************************************</p><p>To dive deeper in the code on how the animation is being orchestrated with Compose, you can check my project ComposableSearch from the link below. Finally, here’s what it looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*rcPCdbc5-BIMQW8Kk9_XKA.gif" /><figcaption>GitHub: <a href="https://github.com/Aimannab/ComposableSearchApp">https://github.com/Aimannab/ComposableSearchApp</a></figcaption></figure><p>In case you’re wondering, I thought I’d make the search bar developed with Jetpack Compose stand out more (for obvious reasons) by adding a gradient background as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c9a154998372e3cb1acdbd20988a069/href">https://medium.com/media/3c9a154998372e3cb1acdbd20988a069/href</a></iframe><p>And Voila!</p><p>Trying not to be biased here, but Jetpack Compose has so much to offer! It’s like we are getting a second chance in life to correct our past mistakes.</p><p>Yet, it’s a completely new way of developing apps that you’d have to learn. With the <a href="https://medium.com/u/e1f26db83092">Android Developers</a> community so active on this subject (especially on Twitter), I believe these are very exciting times to be working with Android technologies!</p><p>What I’m most looking forward to is being able to do a seamless migration of an entire app to Jetpack Compose one day!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa616c270b5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/to-compose-or-not-to-compose-that-is-the-question-fa616c270b5">To Compose, or Not to Compose, That is the Question</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>