<?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 Arbaz Pirwani on Medium]]></title>
        <description><![CDATA[Stories by Arbaz Pirwani on Medium]]></description>
        <link>https://medium.com/@arbazpirwani?source=rss-1e3492e05544------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*H6Ds8Qv5nVCJo5FEqES3kA.jpeg</url>
            <title>Stories by Arbaz Pirwani on Medium</title>
            <link>https://medium.com/@arbazpirwani?source=rss-1e3492e05544------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 11:39:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@arbazpirwani/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[Android Studio 4.0 Canary: Motion Editor!]]></title>
            <link>https://medium.com/@arbazpirwani/android-studio-4-0-canary-motion-editor-f69bce614881?source=rss-1e3492e05544------2</link>
            <guid isPermaLink="false">https://medium.com/p/f69bce614881</guid>
            <category><![CDATA[android-studio]]></category>
            <category><![CDATA[motion-editor]]></category>
            <category><![CDATA[motionlayout]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Arbaz Pirwani]]></dc:creator>
            <pubDate>Fri, 25 Oct 2019 10:10:06 GMT</pubDate>
            <atom:updated>2019-11-01T12:46:30.097Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Android Studio 4.0 Canary 1 available" src="https://cdn-images-1.medium.com/max/200/1*yetvFWePqoDz1eDVANa6BQ.png" /><figcaption>Android Studio 4.0 Canary 1</figcaption></figure><blockquote><em>Android Studio 4.0 Canary 1 is now available in the Canary and Dev channels.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jwbEddcMGHxgVI26snbYDA.png" /></figure><p>If you want to check the update you can check it from <strong>Help</strong> &gt; <strong>Check for Updates </strong>(<strong>Android Studio</strong> &gt; <strong>Check for Updates</strong> on macOS). Otherwise, you can <a href="https://developer.android.com/studio/preview/index.html">download it here</a>.</p><p>This version of Android Studio has some of the new, cool features including <strong>Jetpack Compose toolkit</strong>, <strong>Java 8 Library desugaring in D8 and R8</strong>, <strong>Smart editor features when editing R8/ProGuard rules</strong>, <strong>Support for Kotlin DSL script files</strong>, <strong>Kotlin Android live templates</strong>, <strong>Fragment wizard</strong> and <strong>new fragment templates</strong>.</p><p>You can see the full update notes <a href="https://androidstudio.googleblog.com/2019/10/android-studio-40-canary-1-available.html"><em>here</em></a></p><p>But the coolest feature that this Canary version has is <strong>“Motion Editor”</strong></p><p>Android Studio now includes a visual design editor for the <strong><em>MotionLayout</em></strong> layout type, making it easier to create and preview animations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*p7y47JaScNkdUpinwU4P9w.gif" /></figure><p>The Motion Editor provides a simple interface for manipulating elements from the MotionLayout library that serves as the foundation for animation in Android apps. In previous releases, creating and altering these elements required manually editing constraints in XML resource files. Now, the Motion Editor can generate this XML for you, with support for start and end states, keyframes, transitions, and timelines.</p><h3>Getting Started with MotionLayout</h3><p>Follow these steps to start using MotionLayout in your project.</p><p><strong>Add the `ConstraintLayout` dependency</strong>: To use <em>MotionLayout</em> in your project, add the <em>ConstraintLayout</em> 2.0 dependency to your app’s <em>build.gradle</em> file. If you’re using AndroidX, add the following dependency:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VMgyyS-ok1MSeExFZzRk7A.png" /></figure><p>If you’re not using AndroidX, add the following support library dependency:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oIIAouNJqf0yXOnv0WezIQ.png" /></figure><p>Following guide will follow the AndroidX Artifacts. You can use support Library as well and if you like to <strong>migrate</strong> to <strong>AndroidX</strong> you can do it from <strong>Refactor</strong> &gt; <strong>Migrate to AndroidX</strong> on your Android Studio!<br>“<em>Make sure to Backup your project as Zip</em>” so you can’t blame me :P</p><p>So great we are now ready to go ahead.</p><p><strong>Create a</strong> <em>MotionLayout</em> <strong>file</strong>: <em>MotionLayout</em> is a subclass of <em>ConstraintLayout</em>, so you can transform any existing <em>ConstraintLayout</em> into a <em>MotionLayout</em> by replacing the class name in your layout resource file, as shown in the following examples:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NaYye6ody_-kJPRfmxu5cA.png" /></figure><p>Here’s a full example MotionLayout file that can be used to create the motion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0IF16aCl0QJEI9GWGniN7w.png" /></figure><p><strong>Create a MotionScene</strong>: In the previous <em>MotionLayout</em> example, the <em>app:layoutDescription</em> attribute references a MotionScene. A MotionScene is an XML resource file that contains all of the motion descriptions for the corresponding layout. To keep layout information separate from motion descriptions, each <em>MotionLayout</em> references a separate MotionScene. Note that definitions in the MotionScene take precedence over any similar definitions in the <em>MotionLayout</em>.</p><p>Here’s an example MotionScene file that describes the basic horizontal motion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*olhVz031697whDruorCohQ.png" /></figure><h4>Note the following:</h4><p>&lt;Transition&gt; contains the base definition of the motion.</p><ul><li>motion:constraintSetStart and motion:constraintSetEnd are references to the endpoints of the motion. These endpoints are defined in the &lt;ConstraintSet&gt; elements later in the MotionScene.</li><li>motion:duration specifies the number of milliseconds that it takes for the motion to complete.</li></ul><p>&lt;OnSwipe&gt; lets you control the motion via touch.</p><ul><li>motion:touchAnchorId refers to the view that you can swipe and drag.</li><li>motion:touchAnchorSide means that we are dragging the view from the right side.</li><li>motion:dragDirection refers to the <em>progress</em> direction of the drag. For example, motion:dragDirection=&quot;dragRight&quot; means that progress increases as you drag to the right.</li></ul><p>&lt;ConstraintSet&gt; is where you define the various constraints that describe your motion. In this example, we define one ConstraintSet for each endpoint of our motion. These endpoints are centered vertically (via app:layout_constraintTop_toTopOf=&quot;parent&quot; and app:layout_constraintBottom_toBottomOf=&quot;parent&quot;). Horizontally, the endpoints are at the far left and right sides of the screen.</p><p>For a more detailed look at the various elements that MotionScene supports, see the <a href="https://developer.android.com/training/constraint-layout/motion-layout-examples">MotionLayout examples</a>.</p><h3>Interpolated attributes</h3><p>Within a MotionScene file, <em>ConstraintSet</em> elements can contain additional attributes that are interpolated during transition. In addition to position and bounds, the following attributes are interpolated by <em>MotionLayout</em>:</p><ul><li>alpha</li><li>visibility</li><li>elevation</li><li>rotation, rotationX, rotationY</li><li>translationX, translationY, translationZ</li><li>scaleX, scaleY</li></ul><h3>Custom attributes</h3><p>Within a <em>&lt;Constraint&gt;</em>, you can use the <em>&lt;CustomAttribute&gt;</em> element to specify a transition for attributes that aren’t simply related to position or <em>View</em> attributes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GIxVfEUz2MrA3axpii5arA.png" /></figure><p>A <em>&lt;CustomAttribute&gt;</em> contains two attributes of its own:</p><ol><li>motion:attributeName is required and must match an object with getter and setter methods. The getter and setter much match a specific pattern. For example, backgroundColor is supported, since our view has underlying getBackgroundColor() and setBackgroundColor() methods.</li><li>The other attribute you must provide is based on the value type. Choose from the following supported types:</li></ol><ul><li>motion:customColorValue for colors</li><li>motion:customIntegerValue for integers</li><li>motion:customFloatValue for floats</li><li>motion:customStringValue for strings</li><li>motion:customDimension for dimensions</li><li>motion:customBoolean for booleans</li></ul><p>Note that when specifying a custom attribute, you must define endpoint values in both the start and end <em>&lt;ConstraintSet&gt;</em> elements.</p><h4>Example: Change background color</h4><p>Building on our previous example, let’s have the view change colors as part of its motion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*liMEJprPa8wI-3nE5ilmaw.gif" /></figure><p>Add a <em>&lt;CustomAttribute&gt;</em> element to each <em>ConstraintSet</em> elements, as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tj2PeGoZnxCBzfWs_s_eMQ.png" /></figure><h3>Additional MotionLayout attributes</h3><p>In addition to the attributes in the example above, <em>MotionLayout</em> has other attributes that you might want to specify:</p><ul><li>app:applyMotionScene=&quot;boolean&quot; indicates whether to apply the MotionScene. The default value for this attribute is true.</li><li>app:showPaths=&quot;boolean&quot; indicates whether to show the motion paths as the motion is running. The default value for this attribute is false.</li><li>app:progress=&quot;float&quot; lets you explicitly specify transition progress. You can use any floating-point value from 0 (the start of the transition) to 1 (the end of the transition).</li><li>app:currentState=&quot;reference&quot; lets you specify a specific ConstraintSet.</li><li>app:motionDebug lets you display additional debug information about the motion. Possible values are &quot;SHOW_PROGRESS&quot;, &quot;SHOW_PATH&quot;, or &quot;SHOW_ALL&quot;.</li></ul><h3>Getting Started with Motion Editor!</h3><p>As previously mentioned</p><p>The Motion Editor provides a simple interface for manipulating elements from the MotionLayout library that serves as the foundation for animation in Android apps. In previous releases, creating and altering these elements required manually editing constraints in XML resource files. Now, the Motion Editor can generate this XML for you, with support for start and end states, keyframes, transitions, and timelines.</p><p>Here I have created one layout using Constraint layout</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4xAtGQwOf2Uylj3-" /></figure><p>As you can see I have a simple layout with ImageView and TextView in <em>ConstraintLayout</em></p><p>Simply right click on it and select Convert to <em>MotionLayout</em> as the following picture shows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hK-Zf1dSStVijT5R" /></figure><p>It will migrate into <em>MotionLayout</em> from <em>ConstraintLayout</em> plus create a scene file that’s gonna store all the key frame that we’re about to create</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wyE2RtJ2SynckqNZ" /></figure><p>Select the <strong>Start State</strong> and change some of the view’s constraint for instance:</p><p>Like remove bottom and end constraint to see a preview of your both views or more views to see changes as I have done here</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/0*KAyu5iB6vGPtLfV2" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/0*ogz3D1V4BlPtsNj2" /></figure><p>You can even see the end result by clicking <strong>End State</strong>.</p><p>Also we can go to MotionLayout back and turn on show lines path from A<strong>ttribute Panel</strong> to see how this view going to move.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/0*nPBjZaI3OA9X8u-A" /></figure><p>Now as we have changed the layout we can move to <strong>Transition Panel </strong>By clicking the linking arrow between the two states.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/0*g_JSRqeZFeBcuzFh" /></figure><p>Here is your <strong><em>Motion Editor</em> Transition Panel</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jetDu6VCcLKqLCcQ" /></figure><p>You can simply play your animation from <strong>Transition Panel.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/0*9uNXzVg6TaA_U8c9" /></figure><p>You can see real time animation in this <strong>Motion Editor</strong> also with transition path as where your animation is and how your animation is going to start and end.</p><p>Here you will find multiple options to view your transitions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/0*05STpImJrcDiQtXH" /></figure><p><strong>Play/Pause</strong> for your animation.</p><p><strong>Move Backward</strong> to start your animation.</p><p><strong>Move Forward</strong> to end your animation.</p><p><strong>Direction Changer</strong> to change your animation from start to end or end to start and even both at the same time!</p><p><strong>Playback Speed</strong> to see your animations on different scale of speed on a runtime to slow motion or fast forward.</p><p>As these names are given by me to the tools so you will find proper name from the document.</p><p>So the next thing we can do is we can make this animation a bit interesting. So you can add a <strong>keyframe</strong> at any point of <em>transition</em> from option in <strong>Transition Panel’s</strong> right corner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XiK86SipNWbkWzl7" /></figure><p>Here you can find various options to add <strong>keyframe </strong>to your <em>transition</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_wilBfC0pzhdus2T" /></figure><p>We have different types of <strong>keyframes</strong>,<strong> </strong>first we are going to use <em>position</em> based <em>keyframe</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*x56dP7bSQ_O7kQqu" /></figure><p>So we have selected <em>textView</em> as target view, and type to <em>parentRelative</em> and want to set <strong>X </strong>position to 100% so we add 1 in <em>PercentX</em> as we use 1 based percentage in Android!</p><p>So after adding it you can see it is already look a bit interesting, now let’s play it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/0*POd33wrJxm_zz0kI" /></figure><p>We have 5 types of <strong>keyframes</strong> so let’s apply some of them and see how it will come up with an end result.</p><p>Some interesting and weird results are now here what I have done here is that I have added alpha animation to <strong>ImageView</strong> with <em>key attribute</em>, another <em>key attribute</em> <strong>rotation</strong> to <strong>TextView</strong> to rotate it and remove one other constraint of <strong>ImageView</strong> to see the end result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/0*P5ogTw6bXSQ-FvS_" /></figure><p>You can find your <strong>scene file</strong> that holds every <em>transition</em> details and <strong>constraint</strong> sets, from the <strong>res/xml</strong> directory.</p><h3>Conclusion</h3><p>We have seen Android Canary 1 is out with some of the cool latest features, as it is in Canary version it has some bugs which will be fixed in the stable release, but still it is ready to use and explore it and especially in this Article we have discussed.</p><ul><li><strong>Motion Layout</strong></li><li><strong>MotionScene</strong></li><li><strong>Transitions</strong></li><li><strong>Interpolated attributes</strong></li><li><strong>Custom attributes</strong></li><li><strong>Additional MotionLayout attributes</strong></li><li><strong>Motion Editor</strong></li><li><strong>KeyFrames</strong></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f69bce614881" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>