<?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 Vishal Sehgal 🆚 on Medium]]></title>
        <description><![CDATA[Stories by Vishal Sehgal 🆚 on Medium]]></description>
        <link>https://medium.com/@vishalsehgal?source=rss-6ed89dc846bc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*doSF2p5AzE4wjACt8hkGaw.jpeg</url>
            <title>Stories by Vishal Sehgal 🆚 on Medium</title>
            <link>https://medium.com/@vishalsehgal?source=rss-6ed89dc846bc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 08:38:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vishalsehgal/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[Expand/Collapse FAB on Scrolling like Google’s Message App]]></title>
            <link>https://vishalsehgal.medium.com/expand-collapse-fab-on-scrolling-like-googles-message-app-484df2d9d246?source=rss-6ed89dc846bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/484df2d9d246</guid>
            <category><![CDATA[material-design]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[nestedrecyclerview]]></category>
            <category><![CDATA[recyclerview]]></category>
            <category><![CDATA[animation]]></category>
            <dc:creator><![CDATA[Vishal Sehgal ]]></dc:creator>
            <pubDate>Fri, 21 Jun 2019 22:29:01 GMT</pubDate>
            <atom:updated>2019-06-24T23:33:45.118Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>When it comes to design your Android app’s User Interface(UI) or User Experience(UX) Google’s </strong><a href="https://medium.com/u/413d230e5fe2"><strong>Material Design</strong></a><strong> </strong><a href="http://material.io/"><strong>principles</strong></a><strong> are the best follow up to make your app a huge success with best practices.</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1AdEok6D02fb5S_Ks0Uh-w.gif" /><figcaption>Custom Material Design FAB</figcaption></figure><p>As you may have discerned that Google always gives the first preview of the latest material design components in their own apps and Yes, they are really cool! 🤯 and Now you may be questioning where you can find out the list of those components(widgets) and keep yourself up-to-date, well Thanks to <a href="https://medium.com/u/991272e72e68">Google Developers</a> team who are putting great efforts to provide excellent content and documentation to the developers and their consumers at this coolest place {<a href="http://material.io/"><em>Material.io</em></a><em>} </em>👀</p><p>Now, let’s move forward and look at what we are going to achieve from this article.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*HZM7zrIrMRmWImWeVYNUUA.gif" /><figcaption>Left one is Google’s Original Message App &amp;&amp; Right one is what we will built</figcaption></figure><h4>Concept:</h4><p>We are going to play with <strong>NestedScrollView </strong>and it’s <strong>setOnScrollChangeListener() </strong>method.<br><strong>// </strong>this method has a callback <strong>onScrollChange() </strong>by which we will observe the change in <em>scrolling</em> and <strong>expand</strong> or <strong>collapse</strong> our FAB accordingly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*jx2Lvh4XVN3fG09V3Ws5bQ.png" /></figure><h3>Step 1:</h3><p>Start a new Android Studio Project and proceed with selecting an empty activity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*uQ14OnFbvUOsT8nHngjetg.png" /></figure><h3>Step 2:</h3><p>Name it as <em>GoogleMessageApp</em>(you can name it whatever you like) and select your project language as <strong>Kotlin</strong> and also check on the “<strong>Use AndroidX artifacts</strong>” and then press on that finish button. Hang on a minute or two till the Gradle builds successfully.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*74J8_pEkScdBmrxwI2Njqg.png" /><figcaption>That’s how your Android Studio will look like after pressing the Finish button.</figcaption></figure><blockquote>We are going to make changes(or adding code) in the files which are marked with red boxes in the above image.</blockquote><h4>Step 3:</h4><p>Open your <strong>build.gradle(Module: app)</strong> file and add the material library dependency inside the <strong>dependencies{} </strong>block and <em>sync</em> your project.</p><pre>implementation &#39;com.google.android.material:material:1.0.0&#39;</pre><h4>Step 4:</h4><p>Create a new drawable file under <em>res/drawable</em> and name it as <strong>fab_btn_corner.xml <br></strong>This will be the background of our custom fab which you can see in the next step.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/14262ce971742c111ed0b772b5c257ce/href">https://medium.com/media/14262ce971742c111ed0b772b5c257ce/href</a></iframe><h4><strong>Step 5:</strong></h4><p>Now open the <em>activity_main.xml </em>file and add the below code in it</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f2f49d27553dc84e5af8120ba2c9f6d6/href">https://medium.com/media/f2f49d27553dc84e5af8120ba2c9f6d6/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bEvX7GXVeEOngtrEIKNe6Q.png" /><figcaption>Layered Illustration of the above layout.</figcaption></figure><p>Let’s talk a bit about why we’ve chosen <strong>CoordinatorLayout</strong>. Because It is a <strong>super-powered FrameLayout</strong> and is a general purpose container that allows for coordinating interactive behaviors between its children and it is also managed interactions between its children, and as such needs to contain all the views that interact with each other. The two general cases supported by CoordinatorLayout are:</p><ul><li><em>A top-level content layout (meaning CoordinatorLayout is at the root of all views within an activity or a fragment).</em></li><li><em>As a container for a specific interaction with one or more child views.</em></li></ul><p>Now take a look at the layout code and the above picture carefully and I hope you’ll get an Idea how the things are actually working with CoordinatorLayout.</p><p><strong>NestedScrollView </strong>is just like <a href="https://developer.android.com/reference/android/widget/ScrollView.html">ScrollView</a>, but it supports acting as both a nested scrolling parent and child. In simple language, it is a widget that is used when we want to implement a scrollable view inside another scrollable view.</p><h4><strong>Step 6:</strong></h4><p>Now add your content inside the <em>NestedRecyclerView</em> and make sure the content or the list takes more space outside of your device screen. In this article, I am not going to teach you how to build <em>RecyclerView</em> and populate data into it. For that, you can check out the project on my Github from the link mentioned below.</p><p>In your <strong>MainActivity.kt</strong> file create a new function and name it as <strong>handleFAB()<br></strong>and add the below code in it after that call it inside your activity’s <strong>onCreate() </strong>method</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7cf4a3068b400a98acafb4dee5168c8e/href">https://medium.com/media/7cf4a3068b400a98acafb4dee5168c8e/href</a></iframe><p>What we are doing here is whenever there is up scrolling detected we are hiding the <strong>fabTitle</strong>(Start chat) and showing it again when the user scrolls it down again.<br>Well, the whole magic here is done by <strong>android:animateLayoutChanges=”true” </strong>with the <strong>LinearLayout </strong>as it helps animate their children when their <em>visibilities</em> or <em>size </em>changes. And without it(or <strong>android:animateLayoutChanges=”false”</strong>) the expanding/ collapsing animation may look something like this,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*Ob7269PjQ2qy_dk8aN2FWg.gif" /><figcaption>Laggy Animation!! Isn&#39;t it?</figcaption></figure><h4>Step 7:</h4><p>🎉Ta-da!! Take a deep breathe as this is the final step in which you just have to run your project on your 📲 and try it…</p><h4>Note:</h4><ul><li>Don’t forget to set your Activity’s theme to<br><strong>Theme.MaterialComponents.Light.NoActionBar</strong></li><li>You can find the drawables and other <em>resources</em> in the Github Repo.</li></ul><p>So, we have covered so many <strong>different</strong> topics in this article. I hope you may have learned something from this and understand the concepts used above. Now, you have a basic understanding of how to play with <em>scrolling</em>, looking forward to seeing what you can build more with it. 🧐</p><p>Here is the <a href="https://github.com/CoderVishalSehgal/Google-Message-App-FAB-Clone">link</a> to <em>Github Repository</em> of the project and the sample APK <a href="https://github.com/CoderVishalSehgal/Google-Message-App-FAB-Clone/raw/master/app/sample-app.apk">file</a> to test on your device.</p><h4>If you found this article helpful then please don’t forget to 👏🏼 for yourself as you have acquired something new today.</h4><h4>You can connect with me on <a href="https://www.linkedin.com/in/codervishalsehgal/">LinkedIn</a> and follow on <a href="https://twitter.com/vishalsehgal31">Twitter</a> 🤓</h4><figure><a href="https://usejournal.com/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=tech&amp;utm_content=guest_post_image"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PYxBP_WV7LI6zc-zdUkNqQ.png" /></a></figure><p>📝 Read this story later in <a href="https://blog.usejournal.com/r/?url=https%3A%2F%2Fusejournal.com%2F%3Futm_source%3Dmedium.com%26utm_medium%3Dnoteworthy_blog%26utm_campaign%3Dtech%26utm_content%3Dguest_post_read_later_text">Journal</a>.</p><p>👩‍💻 Wake up every Sunday morning to the week’s most noteworthy stories in Tech waiting in your inbox. <a href="https://blog.usejournal.com/r/?url=https%3A%2F%2Fusejournal.com%2Fnewsletter%2Fnoteworthy-in-tech%2F%3Futm_source%3Dmedium.com%26utm_medium%3Dnoteworthy_blog%26utm_campaign%3Dtech%26utm_content%3Dguest_post_text">Read the Noteworthy in Tech newsletter</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=484df2d9d246" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>