<?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 Peter Pazmandi on Medium]]></title>
        <description><![CDATA[Stories by Peter Pazmandi on Medium]]></description>
        <link>https://medium.com/@peter.pazmandi?source=rss-6d8bc01d8719------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*lZ5sB-NVwfAj5XGueVZjwQ.jpeg</url>
            <title>Stories by Peter Pazmandi on Medium</title>
            <link>https://medium.com/@peter.pazmandi?source=rss-6d8bc01d8719------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 30 May 2026 17:31:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@peter.pazmandi/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 MotionLayout — Clearing weather]]></title>
            <link>https://medium.com/@peter.pazmandi/android-motionlayout-clearing-weather-713a3ed5170c?source=rss-6d8bc01d8719------2</link>
            <guid isPermaLink="false">https://medium.com/p/713a3ed5170c</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[motionlayout]]></category>
            <category><![CDATA[motionscene]]></category>
            <category><![CDATA[animation]]></category>
            <dc:creator><![CDATA[Peter Pazmandi]]></dc:creator>
            <pubDate>Mon, 16 Nov 2020 18:32:22 GMT</pubDate>
            <atom:updated>2020-11-16T19:04:51.373Z</atom:updated>
            <content:encoded><![CDATA[<h3>Android MotionLayout — Clearing weather</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UGcyw6TGFZ52cQllFeiw_Q.png" /></figure><p><strong>In this tutorial we are going to build up a simple clearing weather animation using MotionLayout.</strong></p><p><strong>This animation will contain a changing background color, and 2 moving clouds, which are going to move out to the left and right of the screen.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*-qbcY8nyuE2XdusikcmkEw.gif" /></figure><blockquote>We are going to implement a click listener also. It means, the animation will start only when we click on it.</blockquote><blockquote>When the animation is started and finished, then we gonna show a <strong>Toast </strong>message. So, we gonna learn how to add events to the states of the Transition as well.</blockquote><h4><strong>Android WeatherApp Course</strong></h4><p>This tutorial is part of my WeatherApp course. In this course you can build up a whole application using the OpenWeatherMaps API.<br>If you would like to do this course, then you can find it under the link: <a href="https://inspirecoding.app/courses/weatherapp/">Android WeatherApp course</a></p><h3>MotionLayout</h3><p><strong>MotionLayout</strong> is a layout type, where we can animate the views inside of a layout. Because <strong>MotionLayout </strong>is the subclass of <strong>ConstraintLayout</strong>, we can use all of its cool features.</p><p>In a <strong>MotionLayout </strong>we can animate not only the transitions between the layouts, we can either animate the layout properties as well.</p><p>And one more awesome thing, that we can handle events like click and swipe also. Using this feature we can build up much better user interfaces to reach better user experiences.</p><p>MotionLayout uses <strong>XML </strong>to declare the transitions no matter how complex it is.</p><h4>Tags</h4><p>Before we can start the implementation of the tutorial, we should clarify some tags, what we are going to use for this example animation.</p><p>These tags are identified in an <strong>XML </strong>file, which describes the animation. For example the start and the end transitions, moreover the changes of the attributes.</p><p>This <strong>XML </strong>file will be automatically generated by Android Studio when we will convert the <strong>ConstraintLayout </strong>to <strong>MotionLayout</strong>.</p><p>The name of this <strong>XML </strong>is <strong>MotionScene</strong>, which describes the animation.</p><p>There are many tags, but from them we gonnna use the below ones</p><ul><li><strong>&lt;Transition&gt;</strong>: It specifies the animation duration, trigger and how should the views move.</li><li><strong>&lt;OnClick&gt;</strong>: As we have talked about, we can add a click event to the transition…</li><li><strong>&lt;KeyFrameSet&gt;</strong>: Inside of this tag we can add some changes to the views and we can specify in which position of the transition should be done the attribute-change.</li><li><strong>&lt;ConstraintSet&gt;</strong>: This tag will specify the start and the end constraints of the transition.</li><li><strong>&lt;Constraint&gt;</strong>: With this attribute we can match views from the layout XML file to the corresponding ConstraintSet.</li><li><strong>&lt;Layout&gt;</strong>: It will describe the above mentioned views.</li><li><strong>&lt;PropertySet&gt;</strong> and <strong>&lt;Transform&gt;</strong>: With these attributes we can specify some properties of the above mentioned views.</li></ul><p>It can be that after this description you feel yourself a bit lost, but now we will start to implement the sample transition and these attributes gonna be cleaner, I promise. 😎</p><h3>Step 1 — Create new project</h3><p>Our first step is to create a whole new project. For this, launch Android Studio. If you see the <strong>“Welcome page”</strong>, then click on the <strong>“Start a new Android Studio project”</strong>. If you have an open project, then from the <strong>“File”</strong> menu select <strong>“New”</strong>, then <strong>“New Project”</strong>. After thet, this window will popup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*duMo0DUgXYabhykk5P8a-g.png" /></figure><p>Here select the <strong>“Empty Activity”</strong> option. In the next window, we should provide some information about the newly created app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*M_m1d7Jq_aT3eZutrNkgow.png" /></figure><p>This tutorial will be written in <strong>Kotlin</strong>. So, select from the dropdown list the <strong>Kotlin</strong> language.</p><p>From the next list of the <strong>“Minimum SDK”</strong> select API 21. In our case API 21 gonna be enough.</p><p>If you are done, click on the <strong>“Finish”</strong> button. The build can take few minutes. Be patient! 😉</p><p>When the build has been finished, then you should see the open <strong>MainActivity::class</strong> and next to this the <strong>activity_main.xml</strong> files.</p><h3>Step 2 — Update dependency</h3><p>We are going to start this chapter by updating the dependencies of ConstraintLayout for the app. First, open the Module build.gradle file from the left Project pane.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/1*TSYOpQ_I_6itpk8FnFUrbA.png" /></figure><p>Then in the <strong>dependencies{}</strong> section find this line:</p><pre>implementation ‘androidx.constraintlayout:constraintlayout:1.1.3’</pre><p>To start using <strong>MotionLayout </strong>in our project, we have to update the version of <strong>ConstraintLayout</strong> at least to version <strong>2.0.0</strong>. You can find the highest version under the link: [`<a href="https://developer.android.com/jetpack/androidx/releases/constraintlayout">Constraintlayout</a>`]</p><p>When this tutorial was writen, this version was <strong>2.0.0-rc1</strong>, so update the above implementation line to</p><pre>implementation ‘androidx.constraintlayout:constraintlayout:2.0.0-rc1‘</pre><p>Next sync the project by clicking on the <strong>Sync now</strong> button at the top right corner of Android Studio.</p><p>That’s all what we have to do to start using `MotionLayout` in our project.</p><h3>Step 3 — Convert to MotionLayout</h3><p>Next we will convert <strong>ConstraintLayout</strong> of the <strong>activity_main.xml</strong> file to <strong>MotionLayout</strong>. To do this, open it from the <strong>res &gt; layout</strong> folders.</p><p>Open the design view at the right side of Android Studio. Then go to the <strong>Component Tree</strong> pane. Click on <strong>ConstraintLayout </strong>with the right mouse button and select the <strong>“Convert to MotionLayout”</strong> option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F8_Wej8yiCvUaVal0tCyug.png" /></figure><p>After the conversation you should have the below window which is the MotionScene of the activity_main.xml file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2HUECWVZMpaKVzBz4LivYQ.png" /></figure><ol><li>This layout describes the starter position of the <strong>ConstraintSet</strong>…</li><li>… and this is the end.</li><li>After the conversation, our layout got a new attribute also, which describes the <strong>MotionScene </strong>of the layout. You can find this <strong>XML </strong>file in the <strong>res &gt; xml</strong> folder called <strong>activity_main_scene.xml</strong>.</li><li>Using the first icon you can add new <strong>ConstraintSets</strong>, which is a new state what you can start for example from the end of the current <strong>MotionScene</strong>. With the second icon you can add transitions and the third icon is for adding click or swipe event to the transitions.</li><li>This is called Transition. Here you can play with the animation and check what is going to happen with the layout during the animation.</li></ol><h3>Step 4 — The assets</h3><p>Before we can start to implement the layout and the <strong>MotionScene</strong>, we have to add the clouds, the sun and 2 new colors to the<strong> colors.xml</strong> file. Because this step is not the main part of this clearing weather tutorial, we will just add them by downloading the below <strong>ZIP</strong> file.<br><a href="https://developer.android.com/jetpack/androidx/releases/constraintlayout">Clearing Weather assets</a></p><p>After downloading, unzip the file into the <strong>res</strong> folder of your project.</p><h3>Step 5 — The layout</h3><p>The next step is the implementation of the starter layout. So, open the <strong>activity_main.xml</strong> file from the<strong> res &gt; layout</strong> folders and paste into it the below xml code.</p><p>The layout will contain 2 <strong>View</strong>s, which will be the background and 3 <strong>ImageViews </strong>representing the clouds and the sun.</p><pre>activity_main.xml<br></pre><pre>&lt;?xml version=”1.0&quot; encoding=”utf-8&quot;?&gt;<br>&lt;androidx.constraintlayout.motion.widget.MotionLayout<br>    xmlns:android=”<a href="http://schemas.android.com/apk/res/android">http://schemas.android.com/apk/res/android</a>&quot;<br>    xmlns:app=”<a href="http://schemas.android.com/apk/res-auto">http://schemas.android.com/apk/res-auto</a>&quot;<br>    xmlns:tools=”<a href="http://schemas.android.com/tools">http://schemas.android.com/tools</a>&quot;<br>    android:layout_width=”match_parent”<br>    android:layout_height=”match_parent”<br>    app:layoutDescription=”<a href="http://twitter.com/xml/activity_main_scene">@xml/activity_main_scene</a>”<br>    tools:context=”.MainActivity”&gt;</pre><pre>    &lt;View<br>        android:id=”@+id/view_background_gray”<br>        android:layout_width=”match_parent”<br>        android:layout_height=”match_parent”<br>        android:alpha=”1&quot;<br>        android:background=”<a href="http://twitter.com/color/light_grey">@color/light_grey</a>”/&gt;</pre><pre>    &lt;View<br>        android:id=”@+id/view_background_blue”<br>        android:layout_width=”match_parent”<br>        android:layout_height=”match_parent”<br>        android:alpha=”0&quot;<br>        android:background=”<a href="http://twitter.com/color/light_blue">@color/light_blue</a>”/&gt;</pre><pre>    &lt;ImageView<br>        android:id=”@+id/iv_sun”<br>        android:layout_width=”wrap_content”<br>        android:layout_height=”wrap_content”<br>        android:src=”<a href="http://twitter.com/drawable/ic_sun">@drawable/ic_sun</a>”<br>        app:layout_constraintBottom_toBottomOf=”parent”<br>        app:layout_constraintLeft_toLeftOf=”parent”<br>        app:layout_constraintRight_toRightOf=”parent”<br>        app:layout_constraintTop_toTopOf=”parent” /&gt;</pre><pre>    &lt;ImageView<br>        android:id=”@+id/iv_cloud_white”<br>        android:layout_width=”200dp”<br>        android:layout_height=”200dp”<br>        android:elevation=”1dp”<br>        android:src=”<a href="http://twitter.com/drawable/ic_cloud_white">@drawable/ic_cloud_white</a>”<br>        app:layout_constraintBottom_toBottomOf=”parent”<br>        app:layout_constraintLeft_toLeftOf=”parent”<br>        app:layout_constraintHorizontal_bias=”0.2&quot;<br>        app:layout_constraintVertical_bias=”0.45&quot;<br>        app:layout_constraintRight_toRightOf=”parent”<br>        app:layout_constraintTop_toTopOf=”parent” /&gt;</pre><pre>    &lt;ImageView<br>        android:id=”@+id/iv_cloud_grey”<br>        android:layout_width=”150dp”<br>        android:layout_height=”150dp”<br>        android:src=”<a href="http://twitter.com/drawable/ic_cloud_gray">@drawable/ic_cloud_gray</a>”<br>        app:layout_constraintBottom_toBottomOf=”parent”<br>        app:layout_constraintLeft_toLeftOf=”parent”<br>        app:layout_constraintVertical_bias=”0.55&quot;<br>        app:layout_constraintHorizontal_bias=”0.8&quot;<br>        app:layout_constraintRight_toRightOf=”parent”<br>        app:layout_constraintTop_toTopOf=”parent” /&gt;</pre><pre>&lt;/androidx.constraintlayout.motion.widget.MotionLayout&gt;</pre><h3>Step 6 — The clearing weather animation</h3><p>Finally in this step, we can start the implementation of the clearing weather animation.</p><p>There are 2 ways to do thet. Before Android Studio <strong>4.0</strong> you could do that only using the XML file. From version 4.0 the developers can use a graphical interface, which is the <strong>MotionScene</strong>. About this we have talked already. You can open this screen when you open the <strong>activity_main.xml</strong> file and switch to the design view using the icons at the top right corner of Android Studio.</p><p>In this tutorial we gonna do that manually. So we gonna use the design view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ji37H_I5ralPjIziiPA-uA.png" /></figure><h4>The start ConstraintSet</h4><p>As you can see, the starter <strong>ConstraintSet</strong> is already done, because we have inserted the above layout. Note the alpha property of the <strong>view_background_gray </strong>View.</p><h4>The start ConstraintSet</h4><p>Now select the end ConstraintSet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/338/1*HOIZbBH5v0dD3GkbWWLrog.png" /></figure><p>First, we gonna change the transparency of the 2 views. We can do that by setting their <strong>alpha</strong> property.</p><p>From the <strong>ConstraintSet </strong>table, what you can find below of the above screens, select the <strong>view_background_gray</strong> and from the Attributes pane change the alpha from <strong>1 </strong>to <strong>0</strong>.</p><p>Similarly, change the alpha of <strong>view_background_blue </strong>from <strong>0</strong> to <strong>1</strong>.</p><p>Next, select the <strong>iv_cloud_white ImageView</strong>. From its attributes remove the horizontal and the vertical bias lines. You can do it easyily in the right <strong>Attributes pane</strong>.</p><p>Then remove it’s right to right and the left ot left alignments.</p><p>Finally add the left to right alignment with value of parent. You can do in the desing mode if you click in the <strong>Attributes pane</strong> on the plus icon.</p><p>The result is that, the <strong>ImageView </strong>gonna be out from the screen at the right side.</p><p>The last change on the end <strong>ConstraintSet</strong> is to modify the attributes of the <strong>iv_cloud_grey ImageView</strong> as well. So, remove also the bias lines and the left to left — right to right constraints. Thenafter add the right to left constraint with the values of <strong>parent</strong>.</p><h4>The Transition</h4><p>The last thing what we have to set before the first run of the app, is to set the click event.</p><p>This click event will start the transition. We can add it to the <strong>Transition </strong>by clicking on it. You can open it if you click on the arrow which <strong>connects the start and the end ConstraintSets</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*1DDdA7Hhi_Q4YgNnjC4CWA.png" /></figure><p>Thenafter from the Attributes pane, in the <strong>OnClick </strong>part click on the <strong>+</strong> icon and add the below attributes with their values.</p><ul><li><strong>clickActioin</strong> -&gt; toggle</li><li><strong>targetId</strong> -&gt; <a href="http://twitter.com/id/iv_cloud_grey">@id/iv_cloud_grey</a></li></ul><h4>The XML code of the MotionScene</h4><p>If you are stucked, then just copy the below code into the <strong>activity_main_scene.xml </strong>file, what you can find in the <strong>res &gt; xml</strong> folders.</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;MotionScene <br>    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    xmlns:motion=&quot;http://schemas.android.com/apk/res-auto&quot;&gt;<br><br>    &lt;Transition<br>        motion:constraintSetEnd=&quot;@+id/end&quot;<br>        motion:constraintSetStart=&quot;@id/start&quot;<br>        motion:duration=&quot;1000&quot;&gt;<br>       &lt;KeyFrameSet&gt;<br>       &lt;/KeyFrameSet&gt;<br>        &lt;OnClick motion:clickAction=&quot;toggle&quot;<br>            motion:targetId=&quot;@id/iv_cloud_grey&quot; /&gt;<br>    &lt;/Transition&gt;<br><br>    &lt;ConstraintSet android:id=&quot;@+id/start&quot;/&gt;<br><br>    &lt;ConstraintSet android:id=&quot;@+id/end&quot;&gt;<br>        &lt;Constraint<br>            android:id=&quot;@+id/view_background_gray&quot;<br>            android:layout_width=&quot;match_parent&quot;<br>            android:layout_height=&quot;match_parent&quot;<br>            android:alpha=&quot;0&quot; /&gt;<br>        &lt;Constraint<br>            android:id=&quot;@+id/view_background_blue&quot;<br>            android:layout_width=&quot;match_parent&quot;<br>            android:layout_height=&quot;match_parent&quot;<br>            android:alpha=&quot;1&quot; /&gt;<br>        &lt;Constraint<br>            android:id=&quot;@+id/iv_cloud_white&quot;<br>            android:elevation=&quot;1dp&quot;<br>            android:layout_width=&quot;200dp&quot;<br>            android:layout_height=&quot;200dp&quot;<br>            motion:layout_constraintBottom_toBottomOf=&quot;parent&quot;<br>            motion:layout_constraintTop_toTopOf=&quot;parent&quot;<br>            motion:layout_constraintLeft_toRightOf=&quot;parent&quot; /&gt;<br>        &lt;Constraint<br>            android:id=&quot;@+id/iv_cloud_grey&quot;<br>            android:layout_width=&quot;150dp&quot;<br>            android:layout_height=&quot;150dp&quot;<br>            motion:layout_constraintBottom_toBottomOf=&quot;parent&quot;<br>            motion:layout_constraintTop_toTopOf=&quot;parent&quot;<br>            motion:layout_constraintRight_toLeftOf=&quot;parent&quot; /&gt;<br>    &lt;/ConstraintSet&gt;<br>&lt;/MotionScene&gt;</pre><h3>Run the app</h3><p>Now its time to test the app. Connect your real device or start an emulator and run the app.</p><p>When it is loaded, then click on the clouds. The animation needs to run as you can see on this picture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*-qbcY8nyuE2XdusikcmkEw.gif" /></figure><h3>Step 6 — The Transition listener</h3><p>In the last step of this tutorial we are going to implement the Transition listener. <strong>Using this listener we can add some actions to the start / end transitions and of course we can specify actions during the transition as well.</strong></p><p>In our tutorial we are going to show a <strong>Toast </strong>message when the transition has been started and when it is finished.</p><p>First we have to add an id to the <strong>MotionLayout </strong>viewgroup in the <strong>activity_main.xml</strong> file. So open it from the <strong>res &gt; layout</strong> folders and add the below line to the <strong>MotionLayout</strong> viewgroup.</p><pre>android:id=“@+id/motionLayout”</pre><p>Next, open up the <strong>MainActivity::class</strong> file from the main source set.</p><p>We can use the <strong>setTransitionListener()</strong> method to add actions to the transition.</p><p>So, copy and paste the below line into the <strong>onCreate()</strong> method.</p><pre>val motionLayout = findViewById(R.id.motionLayout)<br><br>motionLayout.setTransitionListener(object : MotionLayout.TransitionListener {<br>    override fun onTransitionTrigger(p0: MotionLayout?, p1: Int, p2: Boolean, p3: Float) {<br>    }<br>    override fun onTransitionStarted(p0: MotionLayout?, p1: Int, p2: Int)<br>    {<br>        Toast.makeText(this@MainActivity, &quot;onTransitionStarted&quot;, Toast.LENGTH_SHORT).show()<br>    }<br>    override fun onTransitionChange(p0: MotionLayout?, p1: Int, p2: Int, p3: Float) {<br>    }<br>    override fun onTransitionCompleted(p0: MotionLayout?, p1: Int)<br>    {<br>        Toast.makeText(this@MainActivity, &quot;onTransitionCompleted&quot;, Toast.LENGTH_SHORT).show()<br>    }<br>})</pre><p>First in the code we have to find the view of the <strong>MotionLayout</strong>. Thenafter we use its <strong>setTransitionListener()</strong> method.</p><p>As you can see, it has 4 methods. From them we are going to use only 2, So, we have added a <strong>Toast </strong>to the <strong>onTransitionStarted()</strong> and <strong>onTransitionCompleted()</strong> methods.</p><h3>Run the app</h3><p>Run again the app. When you start the transition and when it is finished, then you will have a `Toast` message on the screen.</p><pre>Congratulations! 😎</pre><p>You just created a cool animation, what maybe you can use in your next app. 😊</p><h3>Run the app</h3><p>The source code is available on GitHub, check it out and download it using the below link.</p><p><a href="https://github.com/inspire-coding/ClearingWeather">GitHub</a></p><h3>Android WeatherApp course</h3><p>Did you like this short tutorial, then check out my <a href="https://inspirecoding.app/courses/weatherapp/">Android WeatherApp course</a> as well.</p><h3>Questions</h3><p>I hope the description was understandable and clear. But, if you have still questions, then leave me comments below! 😉</p><p>Have a nice a day! 🙂</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=713a3ed5170c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Custom Toast with Kotlin extension function]]></title>
            <link>https://medium.com/@peter.pazmandi/custom-toast-with-kotlin-extension-function-81dbc07a6170?source=rss-6d8bc01d8719------2</link>
            <guid isPermaLink="false">https://medium.com/p/81dbc07a6170</guid>
            <category><![CDATA[kotlin-extension]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-tutorials]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Peter Pazmandi]]></dc:creator>
            <pubDate>Sun, 14 Jun 2020 04:43:33 GMT</pubDate>
            <atom:updated>2020-06-14T04:43:33.210Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xl4p017-oHm2DlecAwUJQg.png" /><figcaption>Custom Toast with Kotlin extension function</figcaption></figure><h3>Step 1: Create a new project</h3><p>Frist of all, create a new Android Studio project.</p><h3>Step 2: Create a layout</h3><p>The second step is to create a very simple layout. In our case it will contain only an <strong>EditText </strong>and a <strong>Button</strong>.</p><p>Copy and paste the below code into the <strong>activity_main.xml</strong> file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d4349e00910df06524ed420303d8dcb/href">https://medium.com/media/5d4349e00910df06524ed420303d8dcb/href</a></iframe><h3>Step 3: Create an icon</h3><p>Our Toast message will have an icon as well. So, create a checkmark with the below detailes into the drawable folder.</p><ul><li>Search for done to find the icon</li><li>Create a color in the colors.xml file with the name of green: #78C257</li></ul><h3>Step 4: Create a shape</h3><p>The custom Toast message will have</p><ul><li>a green border</li><li>a light green background</li><li>and rounded corners</li></ul><p>So, create a new shape in the drawable folder and paste into it the below lines.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/15eef23e2485012b2194ee0370be56d9/href">https://medium.com/media/15eef23e2485012b2194ee0370be56d9/href</a></iframe><p>The Hex-code for the light_green color: #B9D7AC</p><h3>Step 5: Create the layout</h3><p>The next is to create the custom layout for the Toast message. So, create a new layout file in the res-layout folder with the name of “<strong>custom_toast</strong>”. Then paste into it the below lines.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc3b709045efb116d1aabaccf2f3aa12/href">https://medium.com/media/dc3b709045efb116d1aabaccf2f3aa12/href</a></iframe><h3>Step 6: Create the extension function</h3><p>In this step first, we have to create a new package and file.</p><ul><li>New Package: util</li><li>New file: ViewExt.kt</li></ul><p>Copy and paste the below code into the new <strong>ViewExt.kt</strong> file</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd191ed6e184281ebc2e9a480d39ec0d/href">https://medium.com/media/dd191ed6e184281ebc2e9a480d39ec0d/href</a></iframe><p>Notes</p><ol><li>Using the <strong>LayoutInflater </strong>we gonna make instance about the layout</li><li>Set the text of the <strong>TextView</strong></li><li>Then we can call the <strong>apply </strong>scope function to set the gravity, the duration and the view.</li></ol><h3>Step 7: Set the click listener</h3><p>The last step is to show our custom Toast message when we click on the Button. So, open the <strong>MainActivity </strong>and paste the below code into the <strong>onCreate()</strong> method.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/43c090ffc43b7571894fbad63e92f669/href">https://medium.com/media/43c090ffc43b7571894fbad63e92f669/href</a></iframe><h3>Run the app</h3><p>Run and test the app. ;)</p><h3>More detailes</h3><p>The whole tutorial is available on my website</p><p><a href="https://inspirecoding.app/custom-toast/">Custom Toast - Inspire Coding - Android development in Kotlin</a></p><p>And you can check the source code on GitHub as well.</p><p><a href="https://github.com/inspire-coding/CustomToastDemo">inspire-coding/CustomToastDemo</a></p><blockquote>Have a nice day :)</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81dbc07a6170" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Custom Toast]]></title>
            <link>https://medium.com/@peter.pazmandi/custom-toast-40ada1e1a065?source=rss-6d8bc01d8719------2</link>
            <guid isPermaLink="false">https://medium.com/p/40ada1e1a065</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[android-tutorials]]></category>
            <dc:creator><![CDATA[Peter Pazmandi]]></dc:creator>
            <pubDate>Fri, 12 Jun 2020 04:08:10 GMT</pubDate>
            <atom:updated>2020-06-12T04:08:10.700Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>In this very simple tutorial I would like to show you how you can create your own custom Toast for your Android application.</strong></p><figure><img alt="Sample custom Toast" src="https://cdn-images-1.medium.com/max/1024/1*xl4p017-oHm2DlecAwUJQg.png" /><figcaption>Sample custom Toast</figcaption></figure><h3>Step 1: Create a new project</h3><p>Frist of all, create a new Android Studio project.</p><h3>Step 2: Create a layout</h3><p>The second step is to create a very simple layout. In our case it will contain only an <strong>EditText </strong>and a <strong>Button</strong>.</p><p>Copy and paste the below code into the <strong>activity_main.xml</strong> file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4121d56c58ba7090ba11a0452e8f2c34/href">https://medium.com/media/4121d56c58ba7090ba11a0452e8f2c34/href</a></iframe><h3>Step 3: Create an icon</h3><p>Our Toast message will have an icon as well. So, create a checkmark with the below detailes into the drawable folder.</p><ul><li>Search for done to find the icon</li><li>Create a color in the colors.xml file with the name of green: #78C257</li></ul><h3>Step 4: Create a shape</h3><p>The custom Toast message will have</p><ul><li>a green border</li><li>a light green background</li><li>and rounded corners</li></ul><p>So, create a new shape in the drawable folder and paste into it the below lines.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cfaf7709c1a80816ed49eba9a2903d13/href">https://medium.com/media/cfaf7709c1a80816ed49eba9a2903d13/href</a></iframe><p>The Hex-code for the light_green color: #B9D7AC</p><h3>Step 5: Create the layout</h3><p>The next is to create the custom layout for the Toast message. So, create a new layout file in the res-layout folder with the name of “<strong>custom_toast</strong>”. Then paste into it the below lines.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fd9380ba4485f581facd6c55ca173da1/href">https://medium.com/media/fd9380ba4485f581facd6c55ca173da1/href</a></iframe><h3>Step 6: Create the Toast</h3><p>Next, we are going to create a method to inflate, position and set the text of the Toast message.</p><p>The below method goes into the <strong>MainActivity::class </strong>after the <strong>onCreate()</strong> method.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a0b776974948e5729574fc501a7e6a3e/href">https://medium.com/media/a0b776974948e5729574fc501a7e6a3e/href</a></iframe><h3>Step 7: Fire up the method</h3><p>The last step is call the above created method in the click listener of our only Button.</p><p>The below lines go into the <strong>onCreate()</strong> method.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a9034071a111de9e1a9f79cbe2bc760b/href">https://medium.com/media/a9034071a111de9e1a9f79cbe2bc760b/href</a></iframe><h3>Run the app</h3><p>That’s all, now you can run the app and test it.</p><h3>More detailes</h3><p>You can find in much more detailes this tutorial on my website.</p><p><a href="https://inspirecoding.app/custom-toast/">Custom Toast - Inspire Coding - Android development in Kotlin</a></p><p>And the whole source code is available on my GitHub page.</p><p><a href="https://github.com/inspire-coding/CustomToastDemo">inspire-coding/CustomToastDemo</a></p><p>If you have any questions, then leave me a comment below. ;)</p><blockquote>Have a nice day :)</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40ada1e1a065" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RelativeLayout — Password checker]]></title>
            <link>https://medium.com/@peter.pazmandi/relativelayout-password-checker-78182d2eb4ba?source=rss-6d8bc01d8719------2</link>
            <guid isPermaLink="false">https://medium.com/p/78182d2eb4ba</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Peter Pazmandi]]></dc:creator>
            <pubDate>Tue, 02 Jun 2020 13:05:54 GMT</pubDate>
            <atom:updated>2020-06-02T13:05:54.430Z</atom:updated>
            <content:encoded><![CDATA[<h3>RelativeLayout — Password checker</h3><figure><img alt="Android Password checker" src="https://cdn-images-1.medium.com/max/983/1*pIKcCN0yVcWKjBa1D56L5w.jpeg" /></figure><p><strong>In this tutorial I would like to show you how you can create a password checker with a modern dark user interface.</strong></p><p>This tutorial is available with more description in Kotlin on <a href="https://inspirecoding.app/relativelayout-password-checker/">inspirecoding.app</a>. If you are looking for the Java version, then you can find it here: <a href="http://uigitdev.com">uigitdev.com</a></p><p>The layout will be very fancy, it will follow the nowdays valid design patterns and it will use dark colors. For this we are going to use very few type of user interface elements, eg <strong>TextViews</strong>, <strong>EditTexts</strong>.</p><h3>Step 1 — Create new project</h3><p>Our first step is to create a whole new project. For this, launch Android Studio and create a new project. If you see the <strong>“Welcome page”</strong> of Android Studio, then click on the <strong>“Start a new Android Studio project”</strong>.</p><ol><li>File — New — New Project</li><li>Empty Activity</li><li>Select Kotlin</li><li>Finish</li></ol><h3>Step 2 — Add the needed dependencies</h3><h4>The dependencies</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/329/1*aOlRQLWWSzzKm-doGzo79A.png" /></figure><p>We are going ot define the dependencies in the <strong>build.gradle (Module: app)</strong> file.</p><p>Copy and paste into the <em>dependencies{}</em> section in the <strong>build.gradle (Module: app)</strong> file the below lines.</p><pre>/** Material design **/<br>implementation “com.google.android.material:$material_version”</pre><pre>/** CardView **/<br>implementation “androidx.cardview:cardview:$cardView_version”</pre><h4>The versions</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/344/1*ssyCdCiYfL8ZzAlsXDiu5A.png" /></figure><p>The versions will be defined in the <strong>build.gradle (Project: app).</strong></p><p>You can find this file next the <strong>build.gradle (Module: app)</strong> file.</p><p>At the top of the file, inside of the <strong>buildscript{}</strong> section you should have the version of Kotlin.</p><p>After it paste the needed versions. After thet the versions should look like below.</p><pre>ext.cardView_version = &#39;1.0.0&#39;<br>ext.kotlin_version = &#39;1.3.72&#39;<br>ext.material_version = &#39;material:1.1.0&#39;</pre><p><strong>Sync the project</strong></p><h3>Step 3 — The ressources</h3><p>We are going to use some extra icons and values. You can download them from Google Drive using the below link.</p><p><a href="https://drive.google.com/file/d/1SNba40i9vj_1Y4lGu9yJ87Xea5lyr-JD/view?usp=sharing">Download ressources</a></p><p>Paste the files into your project’s <strong>res folder</strong>.</p><h3>Step 4 — Build up the user interface</h3><p>Next step is to build up the user interface.</p><p>We are going to separate the views in three parts.</p><ul><li>The email</li><li>The password with the conditions</li><li>The register button</li></ul><p>So, open the <strong>activity_main.xml</strong> file from the <strong>res-&gt;layout</strong> folders.</p><p>Remove the current code with the below one.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/be6bcab1300e7ca8941059b822b7cf7d/href">https://medium.com/media/be6bcab1300e7ca8941059b822b7cf7d/href</a></iframe><h3>Step 5 — Build up the code</h3><p>Alone the above created layout is also pretty cool, but with some line of code it is going to be much better. ;)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/323/1*P76Ghj6R5qKNYyh9lLi5lA.png" /></figure><p>So, from open the <strong>MainActivity.kt</strong> file from the left <strong>Project</strong> tab.</p><p>We have some member variable, which will be partly the view, partly soom Boolean variables, which are used to check the correctness of the fields.</p><p>Then a method to init the view, then the next is to listen to the input in the fields.</p><p>The third method will check the format and the content of the email and password fields.</p><p>The last method will be click listener for the Button, which will be pushed by the user in a real app. If something is wrong, then an error message will be visible under the email and/or password fields, and the user can correct them based on the hint below them.</p><p>The source below goes into the MainActivity::class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/081327d5869116af1281943221dd6b27/href">https://medium.com/media/081327d5869116af1281943221dd6b27/href</a></iframe><h3>Run the app</h3><p>The last step is to check whether the app is running.</p><p>I hope you liked this very short article. If you have question, then leave me a comment below.</p><p>You can find other tutorials like this in Java.</p><p><a href="https://uigitdev.com/">Android Source Codes | UI Elements</a></p><p>… and in Kotlin</p><p><a href="https://inspirecoding.app/">Welcome 😉 - Inspire Coding</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78182d2eb4ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Loading animation]]></title>
            <link>https://medium.com/@peter.pazmandi/loading-animation-5c5b81b1833a?source=rss-6d8bc01d8719------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c5b81b1833a</guid>
            <category><![CDATA[inspire-coding]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[loading-animation]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Peter Pazmandi]]></dc:creator>
            <pubDate>Sun, 24 May 2020 05:40:51 GMT</pubDate>
            <atom:updated>2020-05-24T05:40:51.915Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*t8WX1HN5puXXNmxr" /><figcaption>Photo by <a href="https://unsplash.com/@nordwood?utm_source=medium&amp;utm_medium=referral">NordWood Themes</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this short tutorial I would like to show you how you can create a very simple loading animation for Android application. This tutorial will be written in Kotlin.</p><blockquote>This tutorial assumes you’re already familiar with the basics of Android development.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/217/1*Os6HMTA_3U-UZZhc8-RC7A.gif" /><figcaption>Android loading animation</figcaption></figure><h4>Step 1 — Create a new project</h4><p>The first step is to create a whole new Android Studio project.</p><h4>Step 2 — Add Data Binding</h4><p>In this project we are going to use Data Binding to bind in the code the views.</p><p>Go to the <strong>build.gradle (Module: app) </strong>from the left Project tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/330/1*GTCEj8xxBzF_cQXmL3QH0A.png" /><figcaption>Open the <strong>build.gradle (Module: app)</strong></figcaption></figure><p>Paste the below code at the top of the file to enable the Kotlin annotation for our project.</p><pre>apply plugin: &#39;kotlin-kapt&#39;</pre><p>˛Then enable Data Binding in the android {} section.</p><pre>android <strong>{</strong></pre><pre><strong>    ...</strong></pre><pre><strong>    </strong><em>/** Data Binding **/<br>    </em>dataBinding <strong>{<br>        </strong>enabled true<br>    <strong>}<br>}</strong></pre><p><strong>Convert layout</strong></p><p>Before we can using Data Binding, we have to convert the <strong>activity_main.xml</strong> layout to use it. So open it from the <strong>res - layout</strong> folders</p><p>Put your cursor to the rootview, which is in our case a <strong>ConstraintLayout. </strong>Press there Alt+Enter if you’re using Windows, or <strong>Control/Option+Enter</strong> on Mac. From the Context Actions menu select the “<strong>Convert to data binding layout” </strong>option.</p><p>Now the layout should look like below.</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;layout xmlns:android=&quot;<a href="http://schemas.android.com/apk/res/android">http://schemas.android.com/apk/res/android</a>&quot;<br>    xmlns:app=&quot;<a href="http://schemas.android.com/apk/res-auto">http://schemas.android.com/apk/res-auto</a>&quot;<br>    xmlns:tools=&quot;<a href="http://schemas.android.com/tools">http://schemas.android.com/tools</a>&quot;&gt;</pre><pre>&lt;data&gt;</pre><pre>&lt;/data&gt;</pre><pre>&lt;androidx.constraintlayout.widget.ConstraintLayout<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;match_parent&quot;<br>        tools:context=&quot;.MainActivity&quot;&gt;</pre><pre>&lt;TextView<br>            android:layout_width=&quot;wrap_content&quot;<br>            android:layout_height=&quot;wrap_content&quot;<br>            android:text=&quot;Hello World!&quot;<br>            app:layout_constraintBottom_toBottomOf=&quot;parent&quot;<br>            app:layout_constraintLeft_toLeftOf=&quot;parent&quot;<br>            app:layout_constraintRight_toRightOf=&quot;parent&quot;<br>            app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;</pre><pre>&lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;<br>&lt;/layout&gt;</pre><p>Now, go to the <strong>MainActivity::class. </strong>and add there the binding member variable.</p><pre>private lateinit var binding: ActivityMainBinding</pre><p>Then, we are going to init the variable in the <strong>onCreate()</strong> function.</p><pre>override fun onCreate(savedInstanceState: Bundle?)<br>{<br>    super.onCreate(savedInstanceState)<br>    binding = DataBindingUtil.setContentView(<br>        this,<br>        R.layout.activity_main<br>    )<br>}</pre><h4>Step 3 — Add views to the layout</h4><p>Next, we are going to extend the <strong>activity_main.xml</strong> layout file with an <strong>ImageView </strong>and a <strong>Button</strong>.</p><pre>&lt;ImageView<br>    android:id=&quot;@+id/iv_loading&quot;<br>    android:layout_width=&quot;195dp&quot;<br>    android:layout_height=&quot;34dp&quot;<br>    android:text=&quot;Hello World!&quot;<br>    android:visibility=&quot;invisible&quot;<br>    app:layout_constraintBottom_toBottomOf=&quot;parent&quot;<br>    app:layout_constraintLeft_toLeftOf=&quot;parent&quot;<br>    app:layout_constraintRight_toRightOf=&quot;parent&quot;<br>    app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;</pre><pre>&lt;androidx.appcompat.widget.AppCompatButton<br>    android:id=&quot;@+id/btn_startStopAnimation&quot;<br>    android:layout_width=&quot;wrap_content&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:text=&quot;<a href="http://twitter.com/string/start">@string/start</a>&quot;<br>    android:layout_marginTop=&quot;40dp&quot;<br>    app:layout_constraintTop_toBottomOf=&quot;@+id/iv_loading&quot;<br>    app:layout_constraintLeft_toLeftOf=&quot;parent&quot;<br>    app:layout_constraintRight_toRightOf=&quot;parent&quot; /&gt;</pre><blockquote>The strings are created in the strings.xml file.</blockquote><h4>Step 4 — Add the loading images</h4><p>For the loading animation, we will need 5 images. You can download the SVG files using the below Google Drive link.</p><p><a href="https://drive.google.com/file/d/1yuQR7kbkPhxz9dQTTIyDoKFbH9Qc0tu9/view?usp=sharing">icons_loading.zip</a></p><p>Import them into Android Studio as Vector assets.</p><blockquote>If you are not familiar how to import Vector assets in Android Studio, then check out this.<br><a href="https://inspirecoding.app/loading-animation/#ImportVectorAsset">Import Vector Assets in Android Studio</a></blockquote><h4>Step 5 — Create the animation</h4><p>Go to the res-drawable folder and create there a new <strong>Drawable Ressource File </strong>and name it as <strong>“anim_loading”.</strong></p><p>Paste there the below code.</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;animation-list <br>    xmlns:android=&quot;<a href="http://schemas.android.com/apk/res/android">http://schemas.android.com/apk/res/android</a>&quot;&gt;</pre><pre>&lt;item<br>        android:drawable=&quot;<a href="http://twitter.com/drawable/ic_loading_1">@drawable/ic_loading_1</a>&quot;<br>        android:duration=&quot;200&quot;/&gt;<br>    &lt;item<br>        android:drawable=&quot;<a href="http://twitter.com/drawable/ic_loading_2">@drawable/ic_loading_2</a>&quot;<br>        android:duration=&quot;200&quot;/&gt;<br>    &lt;item<br>        android:drawable=&quot;<a href="http://twitter.com/drawable/ic_loading_3">@drawable/ic_loading_3</a>&quot;<br>        android:duration=&quot;200&quot;/&gt;<br>    &lt;item<br>        android:drawable=&quot;<a href="http://twitter.com/drawable/ic_loading_4">@drawable/ic_loading_4</a>&quot;<br>        android:duration=&quot;200&quot;/&gt;<br>    &lt;item<br>        android:drawable=&quot;<a href="http://twitter.com/drawable/ic_loading_5">@drawable/ic_loading_5</a>&quot;<br>        android:duration=&quot;300&quot;/&gt;<br>    &lt;item<br>        android:drawable=&quot;<a href="http://twitter.com/drawable/ic_loading_4">@drawable/ic_loading_4</a>&quot;<br>        android:duration=&quot;200&quot;/&gt;<br>    &lt;item<br>        android:drawable=&quot;<a href="http://twitter.com/drawable/ic_loading_3">@drawable/ic_loading_3</a>&quot;<br>        android:duration=&quot;200&quot;/&gt;<br>    &lt;item<br>        android:drawable=&quot;<a href="http://twitter.com/drawable/ic_loading_2">@drawable/ic_loading_2</a>&quot;<br>        android:duration=&quot;200&quot;/&gt;<br>    &lt;item<br>        android:drawable=&quot;<a href="http://twitter.com/drawable/ic_loading_1">@drawable/ic_loading_1</a>&quot;<br>        android:duration=&quot;200&quot;/&gt;</pre><pre>&lt;/animation-list&gt;</pre><h4>Step 6— Create the animation</h4><p>Now, open the <strong>MainActivity.kt</strong> file and the below member variable to it.</p><pre>private lateinit var loadingAnimation: AnimationDrawable</pre><p>Thenafter a Boolean variable, which will be the state of the animation. When it is true, the loading is running, but if it is false, then logically it doesn’t run.</p><pre>private var isLoading = false</pre><p><strong>Init cart loading animation</strong></p><p>Next, we are going to create a new function, which will init the animation and we are going to call it from the <strong>onCreate()</strong> method.</p><pre>private fun initCartLoadingAnimation()<br>{<br>    binding.ivLoading.setBackgroundResource(R.drawable.anim_loading)<br>    loadingAnimation = binding.ivLoading.background as AnimationDrawable<br>}</pre><p><strong>The start function</strong></p><p>When we click on the Button, then regarding the value of the isLoading variable, the animation will be started or stopped. The next function will start it. Paste it after the onCreated() method.</p><pre>private fun startLoadingAnimation()<br>{<br>    isLoading = true<br>    binding.btnStartStopAnimation.text = getString(R.string.stop)<br>    binding.ivLoading.visibility = View.VISIBLE<br>    loadingAnimation.start()<br>}</pre><p><strong>The stop function</strong></p><p>Thenafter the stop function</p><pre>private fun stopLoadingAnimation()<br>{<br>    isLoading = false<br>    binding.btnStartStopAnimation.text = getString(R.string.start)<br>    binding.ivLoading.visibility = View.INVISIBLE<br>    loadingAnimation.stop()<br>}</pre><p><strong>The click listener of the Button</strong></p><pre>binding.btnStartStopAnimation.setOnClickListener {<br>    if (isLoading)<br>    {<br>        stopLoadingAnimation()<br>    }<br>    else<br>    {<br>        startLoadingAnimation()<br>    }<br>}</pre><h4>Run the app</h4><p>Finaly, run the app. :)<br>If you made everything correctly, then the animation should looke like on the picture below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/217/1*Os6HMTA_3U-UZZhc8-RC7A.gif" /><figcaption>Loading animation for Android</figcaption></figure><h4>GitHub</h4><p><a href="https://github.com/inspire-coding/LoadingAnimationDemo">inspire-coding/LoadingAnimationDemo</a></p><h4>inspirecoding.app</h4><p>The whole tutorial is availabel under the link with more detailes.</p><p><a href="https://inspirecoding.app/loading-animation/">Loading animation - Inspire Coding - Android development - Kotlin</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c5b81b1833a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>