<?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 Morten Slott Hansen on Medium]]></title>
        <description><![CDATA[Stories by Morten Slott Hansen on Medium]]></description>
        <link>https://medium.com/@mortenslotthansen?source=rss-2a15b014df61------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*rUGUIyEM7rM3aH35.</url>
            <title>Stories by Morten Slott Hansen on Medium</title>
            <link>https://medium.com/@mortenslotthansen?source=rss-2a15b014df61------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 16:35:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mortenslotthansen/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[Tales from the backlog]]></title>
            <link>https://medium.com/@mortenslotthansen/tales-from-the-backlog-28d91b46bcfd?source=rss-2a15b014df61------2</link>
            <guid isPermaLink="false">https://medium.com/p/28d91b46bcfd</guid>
            <category><![CDATA[viewanimator]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[animation]]></category>
            <dc:creator><![CDATA[Morten Slott Hansen]]></dc:creator>
            <pubDate>Sun, 11 Jun 2023 18:17:57 GMT</pubDate>
            <atom:updated>2023-06-11T18:17:57.781Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flashy animation effects using ViewAnimators — Tales from the backlog</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*n0MF1PRTQRkn993iPYzg5w.gif" /><figcaption>View Animators in action</figcaption></figure><p>Having flashy animations <em>might</em> be what makes your app stand out among all the rest. During my time as a developer for Vivino I took great pride in adding polish to the UI and one thing that I’ve often been asked about was how the tool tips animation on the scanning flow was implemented.</p><p>So without further ado here is a breakdown of how the tool tips animation was implemented for the Vivino Scanning when you switch between the 3 flows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/383/1*mXfwvpx4BtAUkMfGzB0OCg.png" /><figcaption>Toolbar with all 3 tool tips showing</figcaption></figure><p>Each tool tip is defined as a basic TextView with a 9 patch background allow for the text to vary in size which is great for localisation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/272/1*zB_XSsT04aB3kS1GzHQurA.png" /><figcaption>9 patch image <strong>bubble_rating</strong> used for the tool tip background</figcaption></figure><p>The TextView is then put inside a ViewAnimator together with an invisible dummy view 0x0 pixels in size and placed above the required view. All that is left now is to define the in and an out animation.</p><pre>&lt;ViewAnimator<br>    android:id=&quot;@+id/tab_label_hint&quot;<br>    android:layout_width=&quot;wrap_content&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:layout_below=&quot;@+id/guide&quot;<br>    android:layout_centerHorizontal=&quot;true&quot;<br>    android:inAnimation=&quot;@anim/slide_in_up_with_fade&quot;<br>    android:outAnimation=&quot;@anim/slide_out_down_with_fade&quot;&gt;<br><br>    &lt;View<br>        android:layout_width=&quot;0dp&quot;<br>        android:layout_height=&quot;0dp&quot; /&gt;<br><br>    &lt;TextView<br>        android:layout_width=&quot;wrap_content&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:layout_marginBottom=&quot;12dp&quot;<br>        android:background=&quot;@drawable/bubble_rating&quot;<br>        android:fontFamily=&quot;@font/graphik_medium&quot;<br>        android:gravity=&quot;center_vertical&quot;<br>        android:paddingLeft=&quot;6dp&quot;<br>        android:paddingTop=&quot;3dp&quot;<br>        android:paddingRight=&quot;6dp&quot;<br>        android:paddingBottom=&quot;6dp&quot;<br>        android:text=&quot;@string/label_hint&quot;<br>        android:textColor=&quot;@color/smoke_247&quot;<br>        android:textSize=&quot;11sp&quot; /&gt;<br>&lt;/ViewAnimator&gt;</pre><p>This is done using an xml animation file to define a set with the two properties we want to animate — translation and alpha. When shown we want it to animate up as it fades in and the same thing in reverse when its dismissed.</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;set xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    android:duration=&quot;300&quot;<br>    android:interpolator=&quot;@android:anim/decelerate_interpolator&quot;<br>    android:shareInterpolator=&quot;true&quot;&gt;<br><br>    &lt;translate<br>        android:fromYDelta=&quot;100%&quot;<br>        android:toYDelta=&quot;0%&quot; /&gt;<br><br>    &lt;alpha<br>        android:fillAfter=&quot;true&quot;<br>        android:fromAlpha=&quot;0.0&quot;<br>        android:toAlpha=&quot;1.0&quot; /&gt;<br>&lt;/set&gt;</pre><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;set xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    android:duration=&quot;300&quot;<br>    android:interpolator=&quot;@android:anim/accelerate_interpolator&quot;<br>    android:shareInterpolator=&quot;true&quot;&gt;<br><br>    &lt;translate<br>        android:fromYDelta=&quot;0%&quot;<br>        android:toYDelta=&quot;100%&quot; /&gt;<br><br>    &lt;alpha<br>        android:fillAfter=&quot;true&quot;<br>        android:fromAlpha=&quot;1.0&quot;<br>        android:toAlpha=&quot;0.0&quot; /&gt;<br>&lt;/set&gt;</pre><p>That is it — now we can trigger the animations indirectly by telling the ViewAnimator what child view to display — remember we defined two views! When calling setDisplayedChild(1) on the ViewAnimator it will automatically animate the view onto screen— and by calling setDisplayedChild(0) it will animate it out. It is now a trivial matter to chain these operations in such a way that they will show the tool tip you want and hide the others.</p><p>The beautiful thing about this approach is that you do not have to worry about canceling animations or check if an animation is already playing etc. etc. — the ViewAnimator takes care of everything.</p><p>When this was created back in 2015 it was pretty cool — not sure if this technique holds up today with the advent of <a href="https://developer.android.com/jetpack/compose">Jetpack Compose</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28d91b46bcfd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>