<?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 Marko Ilicic on Medium]]></title>
        <description><![CDATA[Stories by Marko Ilicic on Medium]]></description>
        <link>https://medium.com/@marko.ilicic?source=rss-c74c907c48fe------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xOPQPqyBcCJOqSDG4kvb4A.jpeg</url>
            <title>Stories by Marko Ilicic on Medium</title>
            <link>https://medium.com/@marko.ilicic?source=rss-c74c907c48fe------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 22:53:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@marko.ilicic/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[Izzy JSON:API parser for Android]]></title>
            <link>https://medium.com/undabot/izzy-json-api-parser-for-android-a51e54a6b8bb?source=rss-c74c907c48fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/a51e54a6b8bb</guid>
            <category><![CDATA[json-api]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[retrofit]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[parsing]]></category>
            <dc:creator><![CDATA[Marko Ilicic]]></dc:creator>
            <pubDate>Wed, 28 Jul 2021 11:15:56 GMT</pubDate>
            <atom:updated>2021-07-28T11:15:56.214Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t1Qn9ByuE8zE_eCPxucEMQ.png" /></figure><p>JSON:API became quite popular some years ago, so we decided to use it in our projects. This helped us model the API resources and responses in a consistent way so everyone who has read the JSON:API documentation can easily understand it.</p><p>In the meantime, we were discussing how to parse it on the mobile side and the first idea was to search some existing JSON:API parser/converter libraries for an Android. There were few and we used a very good solution for the first project. One thing that we noticed was that all these libraries were restricted to a specific JSON parser, so we decided to make our own library which could use different popular parsers and give more flexibility to its consumers. We also wanted to make a contribution to the community with an open source library and this was a perfect opportunity.</p><p>At the time, Gson and Jackson were the most popular JSON parsers so we made<a href="https://github.com/undabot/izzy-json-api-android"><strong> Izzy JSON:API parser</strong></a><strong> implementation for both Gson and Jackson parsers</strong>. It’s currently used in at least two large projects with many customers, and it’s working great for us. It also has support for simple implementation with the Retrofit.</p><p>More improvements are planned in the future and the biggest is to add support for using the Moshi parser — which became quite popular these days due to its simplicity.</p><p>We are looking forward to hearing your feedback on how the library can be improved. Your contributions are very welcome and appreciated.</p><p><strong>Many thanks to the Undabot Android team for the effort and </strong><a href="https://medium.com/u/eb16d09846f"><strong>Ana Seler</strong></a><strong> for the design.</strong></p><p>We need to add a special mention to a little dog girl from our office, who was an inspiration for the library name — thank you Izzy! 🐶</p><p><em>P.S. Izzy Parser is also available for iOS — read the post</em><a href="https://blog.undabot.com/why-did-we-publish-an-open-source-library-for-ios-8bbaed30a159"><em> here</em></a><em>.</em></p><p>Would you like to join Undabot? Check out the open positions on our <a href="https://careers.smartrecruiters.com/undabot">Careers page</a>.<br>Stay up to date with Undabot news by <a href="https://email.undabot.com/x/plugin/?pName=subscribe&amp;MIDRID=S7Y1BAAA38&amp;pLang=en&amp;Z=-691325057">subscribing to our monthly newsletter</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a51e54a6b8bb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/undabot/izzy-json-api-parser-for-android-a51e54a6b8bb">Izzy JSON:API parser for Android</a> was originally published in <a href="https://medium.com/undabot">Undabot</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ConstraintLayout in practice]]></title>
            <link>https://medium.com/undabot/constraintlayout-in-practice-b3e47df7a618?source=rss-c74c907c48fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3e47df7a618</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android-views]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[constraintlayout]]></category>
            <category><![CDATA[undabot]]></category>
            <dc:creator><![CDATA[Marko Ilicic]]></dc:creator>
            <pubDate>Fri, 31 Mar 2017 13:06:58 GMT</pubDate>
            <atom:updated>2022-02-28T12:12:35.054Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_ZGA34N2jm-B46J6iZtFpg.png" /></figure><p><strong>When creating complex and flexible views we need to combine and nest multiple layouts within each other, which often leads to performance issues on lower-end devices, especially when a complex view is used as a list item.</strong></p><p>Android recently released the ConstraintLayout1.0.2 version and within Android Studio 2.3, the ConstraintLayout is used as the default layout in view templates. It should help us create more efficient and flat, but still flexible layouts.</p><h3>Let’s create a happy little view using “old” layouts</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*Hv3gDU3vient5cv71gLNtw.gif" /><figcaption>1. View look and content variations example</figcaption></figure><p>On the left, we have a complex view which can have multiple states, and the views are positioned differently depending on the visibility of other views. Its components are very common and I believe that we’ve all received similar design requirements from our clients and/or designers.</p><p>With this kind of view, it’s impossible to achieve a flat hierarchy and keep the flexibility, even with the RelativeLayout. In this case, we need to combine multiple layouts with nesting to achieve the<em> </em>desired behaviour.</p><p>To achieve this behaviour without using a ConstraintLayout we need to create a hierarchy that looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3f59ac5e2678586b72923a100db92db4/href">https://medium.com/media/3f59ac5e2678586b72923a100db92db4/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*7o8P6XeNWtMR3WSrJevzJQ.png" /><figcaption>2. Design and blueprint in Android studio with layout borders — normal view</figcaption></figure><p>You can see I used a lot of LinearLayouts since I needed to handle cases where other views should take the place of invisible views and everything should wrap evenly. LinearLayout weights are really useful :). Since we all know how to create a similar view, I won’t delve deeper into explaining this, and you can always check the<a href="https://github.com/undabot/blog-constraintlayout-in-practice"> <em>source code</em></a>.</p><h3>Writing XML vs Design mode</h3><p>When I started developing on Android, I wanted to create XML layouts, I mostly used Design mode since it looked easier than writing. But, very soon I realised that writing XML is not as hard as it seemed and I have switched to writing solely in XML. It’s a lot faster and you have a better control on placing views — at least from my experience. New versions of Android Studio added a lot of interesting new features; Design mode brought a lot of good things and I’ve often heard that we should give it a try. I’ve tried using it while building a view with a ConstraintLayout. While it really is good, especially for learning how constraints are created and what happens to the views, I still prefer writing XML than Design mode because Android Studio adds some extra properties which make code less readable and noisy. I’ve found it handy when I use it side-by-side since you can interact with the design and blueprint while writing XML. It’s also very useful when you want to check how the view will react to different constraints.</p><h3>It’s time to create some constraints</h3><p>So, let’s see how my view and hierarchy look after being converted to a ConstraintLayout:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b916f6642686b0180fcc7848b1548b92/href">https://medium.com/media/b916f6642686b0180fcc7848b1548b92/href</a></iframe><p>Well, this looks a lot better now, don’t you think? (except for the LinearLayout, but we’ll get back to it later).</p><p>Just to mention, Android Studio provides the option for converting existing views to ConstraintLayout, but it didn’t really work for me. Maybe it’s ok for simple layouts and maybe it will work better in the future, but I didn’t find it very useful at this moment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*QkfoosxFW5V-TSCZ5SDepA.png" /><figcaption>3. Design and blueprint of a view created with the ConstraintLayout</figcaption></figure><p>On the 3rd image you can see how our view looks cleaner in contrast to the 2nd image while everything remained in its place.</p><p>You may have noticed that I’m not using AspectRatioImageView anymore. That’s because every child in the ConstraintLayout is able to define aspect ratio with the property, e.g:</p><pre>app:layout_constraint<strong>DimensionRatio</strong>=”5:2&quot;</pre><p>Which I find very useful, especially for images.</p><p>All properties that are specific to ConstraintLayoutstart with a app:<strong>layout_constraint</strong>. At first it might look like there are too many of them; and that it’s too complicated for use, but they are really straightforward; e.g. if you want to align a top of the view to a bottom of an another view, simply use the layout_constraint<strong>Top_toBottomOf</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/266/1*y6lobvmZX-x2HnqIWtZtgw.png" /><figcaption>4. FAB constraints</figcaption></figure><p>Also, I didn’t need a helper View to centre FAB to the bottom-right of the image. If you want to centre a certain view to the other view’s side, make constraints from two sides of the view towards the one side of the other view. In my case I have used:</p><pre>app:layout_constraint<strong>Bottom_toBottomOf</strong>=”@+id/image”</pre><pre>app:layout_constraint<strong>Top_toBottomOf</strong>=”@+id/image”</pre><p>And how do we define a view size? Does it work like it does in any other view? Well, we can use a fixed size and wrap_content like with any other view, but we can’t use match_parent any more. I mean, you can try, but Android studio will instantly change that value to some fixed size which it thinks is good; and there is no arguing with him :). Instead, you should use <em>match constraints</em>, aka <em>any size,</em> which is defined by setting the <strong>height</strong> or/and <strong>width</strong> to <strong>zero dp.</strong></p><p>I mentioned that I like weights in the LinearLayout, especially when I need to align multiple views which are prone to visibility changes (I’ve used this a lot in the example). Well, in the ConstraintLayout you can align those views directly without nesting. When a view’s visibility is set to <em>GONE</em>, it actually doesn’t disappear from the layout like in similar layouts.</p><p>Instead, it’s dimensions are set to 0 and the constraints are not lost, so all views which are linked with it will still be in the right place and this makes a UI very responsive. In this case we can also set a specific margin which will be used, e.g:</p><pre>app:layout_<strong>goneMargin</strong>Top=”20dp”</pre><p>Just to mention, all constraints also support <em>start</em> and <em>end</em> attributes for the RTL support.</p><p>As you can see on the 5th picture, I couldn’t make it fully flat, and that’s why I’ve added an additional nesting within the LinearLayout. Buttons are placed below two texts, and the top can be constrained only to the bottom of one of them.</p><p>Let’s say that the buttons are constrained to the description. If the description view has a smaller height than the comments view, the buttons would overlap it, so I had to put them in a new layout which is used for the top constraint of the buttons. Hopefully, we’ll get a solution for these situations in the future and if you already have one, please leave a comment. :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*VCA6sdGageARJiwkD-S-iA.png" /><figcaption>6. Chained buttons</figcaption></figure><p>And lastly, the buttons are nicely packed and centred on the bottom of the view. By making a bi-directional connection between views, we create a chain within the views and it can have one of four styles. I’ve used <strong>&quot;packed”</strong> since they need to be placed in the middle and side by side. If you need some other kind of behaviour, there is also a <strong>&quot;spread&quot;</strong> and <strong>&quot;spread_inside&quot;</strong>. With a combination of <em>0dp</em> on the <em>height</em> or <em>width</em>, it will behave like weights in the LinearLayout, and then we achieve the fourth style. Chain can be vertical or horizontal and their style is set to a “head view” (very top one on a vertical, and a very left one on the horizontal chain) with the:</p><pre>app:layout_constraint<strong>Horizontal_chainStyle</strong>=”<strong>packed</strong>”</pre><p>There are some other features like bias and guidelines, although there was no need to use them in this example, they could be very helpful in many cases.</p><h3>What about performance?</h3><p>We all know that perf matters and we should always make well optimised views. Nested and complex views can create performance issues. Obviously, ConstraintLayout helps with creating flatter views, but how does it affect performance?</p><p>First of, let’s see how view and it’s children are measured on both views.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a1dd3457eae5dd7d33b659f2a4818576/href">https://medium.com/media/a1dd3457eae5dd7d33b659f2a4818576/href</a></iframe><p>We can see that only buttons aren’t measured twice in the “normal” layout. RelativeLayout always has two passes while LinearLayout will make two passes if we use weight, and that’s the case with the first two LinearLayouts.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/23492255705819257f6b5a375c142cab/href">https://medium.com/media/23492255705819257f6b5a375c142cab/href</a></iframe><p>In <strong>ConstraintLayout</strong> some views are measured twice and some only once. That’s because it only measures twice the children whose dimension depend on the constraints which could affect the final height or width of the view. When you set the <em>width</em>or <em>height</em> to <strong>wrap_content</strong> or to a <strong>fixed size</strong>, that view will be measured <strong>once</strong> and that could improve performance. In case you’ve used <strong>match constraints</strong>, that view will be measured <strong>twice</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TNII7OkXdaVEzgXtaTlcGw.png" /><figcaption>7. Speed comparison in milliseconds between views</figcaption></figure><p>I wanted to see some numbers, so I tracked the time between the start of onMeasure() method and the end of onDraw(). Average speed improvement was around <strong>9%</strong> in favour to ConstraintLayout. Average time for LinearLayout was <strong><em>76 ms</em></strong>, and for ConstraintLayout <strong><em>69 ms</em></strong><em>. </em>The device used was <em>Samsung Galaxy S4 mini</em> with <em>KitKat</em>.</p><p>Obviously, the results will depend on the complexity of the view, but ConstraintLayout should generally give better results.</p><h3>Conclusion</h3><p>The ConstraintLayout is great for making flexible and responsive views in Android without having a deep hierarchy and it’s a real step up from the RelativeLayout. You should be able to make more efficient views already and we can only expect that it will get better over time. If you still have performance issues with complex views, and ConstraintLayout doesn’t solve it, I found creating a custom ViewGroup is still the best way to make a fast and fluid UI, but it can also be time consuming.</p><p>So go, play and experiment with it, if you already haven’t. :)</p><p>Thanks to <a href="https://dribbble.com/pixilated">Sinisa Cvahte</a> for the design.</p><p><strong>Thank you for reading. Please comment, like or share it with your friends and we hope to see you soon.</strong></p><p><strong>Would you like to join us? Check out the open positions at our </strong><a href="https://undabot.com/careers/"><strong>Careers page</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3e47df7a618" width="1" height="1" alt=""><hr><p><a href="https://medium.com/undabot/constraintlayout-in-practice-b3e47df7a618">ConstraintLayout in practice</a> was originally published in <a href="https://medium.com/undabot">Undabot</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>