<?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 Leonardo Vinsen on Medium]]></title>
        <description><![CDATA[Stories by Leonardo Vinsen on Medium]]></description>
        <link>https://medium.com/@leonardovinsen?source=rss-a830bc80c240------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xgeIWP9m1mo7KF63T7Ykhg.jpeg</url>
            <title>Stories by Leonardo Vinsen on Medium</title>
            <link>https://medium.com/@leonardovinsen?source=rss-a830bc80c240------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 15:39:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@leonardovinsen/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[Vibe Coding over Coffee ☕]]></title>
            <link>https://leonardovinsen.medium.com/vibe-coding-over-coffee-39481e4fbd1a?source=rss-a830bc80c240------2</link>
            <guid isPermaLink="false">https://medium.com/p/39481e4fbd1a</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[website]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Leonardo Vinsen]]></dc:creator>
            <pubDate>Tue, 24 Mar 2026 08:34:13 GMT</pubDate>
            <atom:updated>2026-03-24T08:34:13.959Z</atom:updated>
            <content:encoded><![CDATA[<p>This article conveys my thoughts and anecdotal experience over AI-assisted coding (popularly referred to as “vibe coding”) over the past 12 months, mainly focusing on Anthropic’s frontier model, Claude.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rHq6XsyS0E-nLeZ7bZd9hA.png" /><figcaption>Source: Andrej Karpathy’s <a href="https://x.com/karpathy/status/1886192184808149383">post on X</a> in Feb 2025.</figcaption></figure><h3><strong>Background</strong></h3><p>I play chess, <em>a lot</em>. My Lichess 2025 Recap says I’ve spent 13 days 2 hours playing on their platform. In addition, I play over-the-board regularly in events hosted by a chess community based in Jakarta, Indonesia called <a href="https://chessnuts.fun/">Chessnuts</a>.</p><p>One day in December 2025, people were sharing their Spotify Wrapped results in one of our chat groups. To which I jokingly responded, <em>“are we doing one [Wrapped] for Chessnuts?”</em>. But the more I thought about it<em>, </em>the more it felt like a good opportunity to experiment with unsupervised agentic programming.</p><p>I started adopting Claude Code in a professional capacity starting mid 2025, erring on the side of being a skeptic, utilizing Claude only for refactors, rubberducking, and generating boilerplate and unit tests. That was until Claude Opus 4.5&#39;s <a href="https://www.anthropic.com/news/claude-opus-4-5">release</a> in November 2025 — where there was a stark contrast in output quality when compared to Claude Opus 4.1.</p><p>And so I decided to build a fully vibe-coded Wrapped website for Chessnuts of my own accord to explore unsupervised agentic programming and a new tech stack: NextJS, Vercel, Drizzle, and Supabase.</p><p>I’ve had professional experience working with adjacent technologies:</p><ul><li>Angular, PHP + jQuery, vanilla HTML + CSS</li><li>Hosting on AWS, GCP and Netlify</li><li>Sequelize and TypeORM</li></ul><p>But never on the stack mentioned above. My knowledge on the chosen libraries and platforms are very limited, so I’m fully relying on Claude.</p><h3><strong>The prototype</strong></h3><p>For the development process, I used Claude Code and the Claude skills <a href="https://github.com/obra/superpowers">obra/superpowers</a> and <a href="https://github.com/anthropics/claude-code/tree/main/plugins/frontend-design">claude-code/frontend-design</a>. All artifacts are stored in the repository as plain .md files — no fancy project management tools.</p><p>The first order of business would be obtaining data of all events hosted by Chessnuts, managed on a platform coincidentally called <a href="https://chessnut.club/">Chess Nut</a> (<em>no, they are not affiliated with each other</em>).</p><p>Fortunately the site exposes a <a href="https://chessnut.club/docs/">Developer API</a> to retrieve list of all events, pairings, and players for a given Chess Club. It even comes in with a very well-written OpenAPI file — good source of context for LLMs.</p><p>Equipped with only superpowers:brainstorm , superpowers:writing-plan and superpowers:execute-plan, I was able to generate a high-level architecture and bite-sized tasks consisting of:</p><ul><li>PostgreSQL schemas</li><li>Drizzle migrations, type definitions, and repository classes</li><li>a script to fetch records from Chess Nut API and insert them into PostgreSQL</li><li>a basic version of the NextJS site to display player stats e.g. Head-to-Head Stats, Most Played Opponent, and Most Frequented Venue.</li></ul><p>The prompt wasn’t that sophisticated either. It was a short .md file that clearly explained the Problem Statement, DB entities constraints and relationships, and stats to display. <em>Good context matters more than fancy workflows.</em></p><p>That said, thebrainstorm skill did do a heavy lifting to clarify edge cases and requirements I hadn’t thought before.</p><p>In roughly 1–2 hours, the prototype was ready. Well, it was very <em>bare</em>, but at least it was sufficient to spark a deeper discussion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O5-9SBcZfeQ2YfEY5vXNLg.png" /><figcaption>Good vibes, bad design.</figcaption></figure><h3>Vibe Coding over Coffee</h3><p>A few days after, I went to meet with the founders of Chessnuts to better understand their pain points. The three of us sat in their home’s patio on a sunny Saturday afternoon.</p><p>The agenda is to discuss what’s still missing — <em>surprise surprise, a lot of them. </em>The prototype consisted of player-oriented stats, but they’d love to see a community-oriented stats as well, e.g. Most Active Players and Rating Leaderboard amongst many other things.</p><p>I noted down the new requirements as new .md files, ran /superpowers:brainstorm and answered Claude’s questions once in a while while we’re chatting and sipping coffee. Once requirements are finalized, Claude prepares a new plan file, and incrementally works on them completely unsupervised.</p><p>The experience felt surreal. In a pre-LLM world, it would take hours or even days to implement the new requirements. Nowadays with agentic coding tools, it’s possible to implement the changes near real-time while stakeholders further ideate on the product in parallel.</p><p>By the end of our session which lasted for a couple hours, <em>all </em>of the new requirements were implemented. There were around 15 new SQL queries added, including a few complicated aggregation ones. In addition to a new page dedicated for Partners.</p><h3>Design</h3><p>All the core functionalities are achieved, but what good is a product if it’s unaesthetically pleasing? We’d love to share the site for all community members to browse and see their stats, but perhaps a bit more color would liven up the experience.</p><p>Invoking frontend-design skill on Claude Web chat, I submitted a prompt to:</p><ul><li>generate a game leaderboard design</li><li>using color palettes obtained from the official Chessnuts website</li><li>providing a Claude-generated overview of the current site’s functionalities as context.</li></ul><p><em>(Not sure why I chose Claude Web chat instead of Claude Code locally, perhaps I wanted to see the design without constraint of existing codebase.)</em></p><pre>Create a &quot;Wrapped&quot; &amp; Leaderboard-style website for a Chess Community in Indonesia called &quot;Chessnuts Indonesia&quot;. I&#39;ve deployed the site here: https://chessnuts-wrapped-website.vercel.app/. You can use it to understand the contents of the page.<br><br>Use the &quot;frontend-design&quot; skill.<br><br>The structure of the site is as follows:<br>&lt;structure&gt;<br># Website Features Overview<br>The Chessnuts Wrapped website is a &quot;Spotify Wrapped&quot;-style statistics site for the Chessnuts Indonesia chess community. All statistics are scoped to 2025 data.<br>## Pages &amp; Routes<br>### Home Page /)<br>The main dashboard showing community-wide chess statistics and leaderboards.<br>**Summary Stats (Header Cards)**:<br>- Total players in community<br>- Total games played (2025)<br>- Total events hosted<br>- Busiest station (partner venue with most events)<br>- Best color overall (white vs black win rate)<br><br>// ... truncated for simplicity<br><br>&lt;/structure&gt;<br><br>Please use the color palette available from https://chessnuts.fun/, which is the community&#39;s official website. Green is their primary color.</pre><p>Copied over the HTML artifact to the codebase, and with a few more minor iterations — voilà, a much aesthetically pleasing site is ready! <em>(at least to my non-designer eyes)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8eZ8Odgpxqp9qvJ-VwxPRA.png" /><figcaption>Final look of the site! Ref: <a href="https://chessnuts-wrapped-website.vercel.app/">https://chessnuts-wrapped-website.vercel.app</a></figcaption></figure><h3><strong>Reflections</strong></h3><p>Of course, LLMs don’t magically solve all problems. Even after all requirements were implemented, looking at my codebase it’s apparent that performance wasn’t taken into consideration.</p><p>I had to do another brainstorming session to implement precomputed stats as the data is never updated but read often. The initial approach was to invoke tens of complicated SQL queries in the homepage — not a good idea. To be fair it wasn’t explicit discussed upfront, so Claude did not take it into account.</p><p>The code wasn’t the best either; plenty of code duplication, randomly adding &#39;use client’ on pages where it’s not required, and scraping logic doing single synchronous inserts instead of batches when appropriate.</p><p>On the positive side, building simple prototypes/products are now more accessible for the vast majority. In a pre-LLM world, I wouldn’t have even bothered spending potentially 20–50 hours on this project. Which means there would’ve been no Wrapped stats for the chess community I’m playing at, and the founders would still be in pain trying to gather community-wide stats.</p><p>Now, small communities — think of your local place of public worship, sports club, schools — can leverage coding agents to build a decent product with minimal resources. It might not be “production-grade”, but hey, if it solves people’s problems, who are we to gatekeep?</p><h3>Final Words</h3><p>While this article generally advocates for usage of AI, one must stay vigilant when using it for an enterprise software. You might’ve seen horror stories of AI usage leading to production DB being deleted, API keys leaked, and outages (including one <a href="https://www.theguardian.com/technology/2026/feb/20/amazon-cloud-outages-ai-tools-amazon-web-services-aws">at Amazon</a>).</p><p>Linus Torvalds has <a href="https://www.youtube.com/watch?v=yEzdHYjY_RU&amp;t=1587s">recently said</a> that AI is just a tool, albeit a great one, comparing it to invention of compilers in the past.</p><p>Ultimately we are responsible for approving and shipping AI generated code, not Anthropic, OpenAI, or any other model providers out there. Treat it as if you wrote it, and exercise sufficient due diligence in reviewing it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39481e4fbd1a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NuxtJS Static Assets Compression with nuxt-compress]]></title>
            <link>https://leonardovinsen.medium.com/nuxtjs-static-assets-compression-with-nuxt-compress-c929f9d62135?source=rss-a830bc80c240------2</link>
            <guid isPermaLink="false">https://medium.com/p/c929f9d62135</guid>
            <category><![CDATA[static-site]]></category>
            <category><![CDATA[nuxtjs]]></category>
            <category><![CDATA[compression]]></category>
            <category><![CDATA[apache]]></category>
            <category><![CDATA[nuxt]]></category>
            <dc:creator><![CDATA[Leonardo Vinsen]]></dc:creator>
            <pubDate>Sat, 19 Dec 2020 12:49:41 GMT</pubDate>
            <atom:updated>2020-12-21T09:56:40.701Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’ve ever ran a Google Lighthouse audit on your static website built with NuxtJS and saw the “Enable text compression” suggestion, then you’ve come to the right place.</p><p>In theory, you can significantly reduce your js, css, and html files by compressing them into gzip or brotli format. Thankfully there’s a package that abstracts this task called nuxt-compress available on <a href="https://github.com/robcresswell/nuxt-compress">Github</a>.</p><p>However, compressing your assets during the build process is only the first step; you also have to configure your web server to serve compressed assets instead of your uncompressed assets. In addition, .html files are not automatically compressed by nuxt-compress (more on this later).</p><p>Let’s start!</p><h3>Installation</h3><ol><li>Install the module</li></ol><pre>npm install nuxt-compress</pre><pre>OR</pre><pre>yarn add nuxt-compress</pre><p>2. Add nuxt-compress to your <a href="https://nuxtjs.org/docs/2.x/configuration-glossary/configuration-modules#buildmodules">buildModules</a></p><pre>module.exports = {<br>  buildModules: [&quot;nuxt-compress&quot;]<br>};</pre><p>If you’re using Nuxt &lt; 2.9, you’ll need to add it to your modules instead.</p><pre>module.exports = {<br>  modules: [&quot;nuxt-compress&quot;]<br>};</pre><p>3. Run your build script (e.g. npm run generate) and your files will be automatically compressed.</p><p>Check your built .js files (mine is in dist/_nuxt) and you should see files ending in .gz and .br</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*HdHrz6SOmKseBGsdFDffEQ.png" /><figcaption>Compressed js files</figcaption></figure><h4>My .html files are not being compressed!</h4><p>You should probably notice that .html files are untouched (read about the issue <a href="https://github.com/nuxt/nuxt.js/issues/6817">here</a>). In the meantime, as a workaround run these two commands after the files are built.</p><pre>// run gzip compression<br>find &lt;build_folder&gt; -type f -iname *.html -exec gzip -k {} &#39;;&#39;</pre><pre>// run brotli compression<br>find &lt;build_folder&gt; -type f -iname *.html -exec brotli {} &#39;;&#39;</pre><p>Or as a package.json script:</p><pre>&quot;scripts&quot;: {</pre><pre>    &quot;postbuild&quot;: &quot;find &lt;build_folder&gt; -type f -iname *.html -exec gzip -k {} &#39;;&#39; ; find &lt;build_folder&gt; -type f -iname *.html -exec brotli --best {} &#39;;&#39;&quot;</pre><pre>}.</pre><pre>//Please note the ; in between commands for gzip and brotli</pre><p>Explanation:</p><ul><li>find &lt;build_folder&gt; -type f -iname *.html searches for all .html files in your build folder (replace &lt;build_folder&gt; with the path to your build folder.</li><li>-exec performs the command you specify after it</li><li>{} is the file(s) that satisfies the find query.</li><li>gzip -k {} &#39;;&#39; runs gzip compression on the file(s). -k flag tells gzip <em>not </em>to delete the original file. Single quotes &#39;;&#39; are added to the delimiter because sometimes the terminal may not recognize that it’s a delimiter.</li><li>Similarly, brotli {} &#39;;&#39; runs brotli compression on the file(s). However, by default original files are not deleted after being compressed.</li><li>Optionally you can add --best flag to use the best compression quality. See man pages for gzip and brotli to learn more.</li></ul><p>You’ve now learnt how to compress your static assets, but there is still one last step — configuring your web server to serve the compressed files instead of the original files.</p><h3>Configuring an Apache Web server</h3><blockquote>Disclaimer: the following code snippet is taken from a <a href="https://blog.desgrange.net/post/2017/04/10/pre-compression-with-gzip-and-brotli-in-apache.html">blogpost</a> written by Laurent Desgrange.</blockquote><p>Add these lines to .htaccess file on your web server root folder.</p><pre>RewriteEngine on</pre><pre># Brotli<br># If the web browser accept brotli encoding… <br>RewriteCond %{HTTP:Accept-encoding} br<br># …and the web browser is fetching a probably pre-compressed file…<br>RewriteCond %{REQUEST_URI} .*\.(css|html|js)<br># …and a matching pre-compressed file exists… <br>RewriteCond %{REQUEST_FILENAME}.br -s<br># …then rewrite the request to deliver the brotli file<br>RewriteRule ^(.+) $1.br<br># For each file format set the correct mime type (otherwise brotli mime type is returned) and prevent Apache for recompressing the files<br>RewriteRule &quot;\.css\.br$&quot; &quot;-&quot; [T=text/css,E=no-brotli,E=no-gzip]<br>RewriteRule &quot;\.html\.br$&quot; &quot;-&quot; [T=text/html,E=no-brotli,E=no-gzip]<br>RewriteRule &quot;\.js\.br$&quot; &quot;-&quot; [T=application/javascript,E=no-brotli,E=no-gzip]<br>        <br># Gzip<br># If the web browser accept gzip encoding… <br>RewriteCond %{HTTP:Accept-Encoding} gzip<br># …and the web browser is fetching a probably pre-compressed file…<br>RewriteCond %{REQUEST_URI} .*\.(css|html|js)<br># …and a matching pre-compressed file exists… <br>RewriteCond %{REQUEST_FILENAME}.gz -s<br># …then rewrite the request to deliver the gzip file<br>RewriteRule ^(.+) $1.gz<br># For each file format set the correct mime type (otherwise gzip mime type is returned) and prevent Apache for recompressing the files<br>RewriteRule &quot;\.css\.gz$&quot; &quot;-&quot; [T=text/css,E=no-brotli,E=no-gzip]<br>RewriteRule &quot;\.html\.gz$&quot; &quot;-&quot; [T=text/html,E=no-brotli,E=no-gzip]<br>RewriteRule &quot;\.js\.gz$&quot; &quot;-&quot; [T=application/javascript,E=no-brotli,E=no-gzip]</pre><pre>&lt;FilesMatch &quot;\.(css|html|js)\.br$&quot;&gt;<br>     # Prevent mime module to set brazilian language header (because the file ends with .br)<br>     RemoveLanguage .br<br>     # Set the correct encoding type<br>     Header set Content-Encoding br<br>     # Force proxies to cache brotli &amp; non-brotli files separately<br>     Header append Vary Accept-Encoding<br>&lt;/FilesMatch&gt;<br>&lt;FilesMatch &quot;\.(css|html|js)\.gz$&quot;&gt;<br>     # Serve correct encoding type<br>     Header set Content-Encoding gzip<br>     # Force proxies to cache gzip &amp; non-gzip files separately<br>     Header append Vary Accept-Encoding<br>&lt;/FilesMatch&gt;</pre><p>Verify that your webserver is now serving compressed assets by looking at Response Headers of one of your js , css or html file, and checking if it contains the header Content-Encoding: br or Content-Encoding: gzip</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*hfKdKkmDGbI0WQCrl4Bdlw.png" /><figcaption>Checking response headers for Content-Encoding: br; previously the file was ~300kB in size!</figcaption></figure><p>That’s all!</p><h3>References</h3><ul><li>‘Enable text compression’ as suggested by Google Lighthouse: <a href="https://web.dev/uses-text-compression/">https://web.dev/uses-text-compression/</a></li><li>nuxt-compress Github page: <a href="https://github.com/robcresswell/nuxt-compress">https://github.com/robcresswell/nuxt-compress</a></li><li>.html files not compressed by compression-webpack-plugin (the plugin used by nuxt-compress ): <a href="https://github.com/nuxt/nuxt.js/issues/6817">https://github.com/nuxt/nuxt.js/issues/6817</a></li><li>‘Pre-compression with gzip and brotli in Apache’ by Laurent Desgrange: <a href="https://blog.desgrange.net/post/2017/04/10/pre-compression-with-gzip-and-brotli-in-apache.html">https://blog.desgrange.net/post/2017/04/10/pre-compression-with-gzip-and-brotli-in-apache.html</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c929f9d62135" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android TabLayout with Gradient Indicator]]></title>
            <link>https://leonardovinsen.medium.com/android-tablayout-with-gradient-indicator-bd49c3a0f4f6?source=rss-a830bc80c240------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd49c3a0f4f6</guid>
            <category><![CDATA[android-tablayout]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[tablayout]]></category>
            <dc:creator><![CDATA[Leonardo Vinsen]]></dc:creator>
            <pubDate>Sat, 06 Apr 2019 06:53:38 GMT</pubDate>
            <atom:updated>2019-04-06T06:53:38.739Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently I was tasked with creating a tab with a gradient colored indicator. I had tried a third-party library and the Support Library TabLayout to get the desired design, but to no avail. At one point I was overriding the onDraw methods to draw my own indicator using Paint and LinearGradient shader, but apparently the gradient was drawn into the TabLayout background instead of the indicator.</p><p>In the end, I came up with an idea to create a custom view with a gradient drawable and place it above the Tab Layout and compute a translation along the x-axis to “slide” it. For this article I have created a new Github project called <a href="https://github.com/leovinsen/GradientTabs">GradientTabs</a> and it looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lixhNg8WS2RIljKHrRMuUQ.png" /><figcaption>TabLayout with custom indicator</figcaption></figure><p>To achieve the desired tab appearance, we need the following:</p><ul><li>A TabLayout with tabIndicatorColor set to null.</li><li>A View with gradient background,</li><li>A ViewPager (we will be using ViewPager.OnPageChangeListener to compute the translation),</li><li>And a FragmentPagerAdapter for the ViewPager.</li></ul><p>Let’s start coding!</p><h3>Libraries needed</h3><p>Add these two libraries to your app build.gradle:</p><pre>implementation <strong>&#39;com.android.support:appcompat-v7:28.0.0&#39;<br></strong>implementation <strong>&#39;com.android.support:design:28.0.0&#39;</strong></pre><h3>Drawables</h3><p>First one is the background for the indicator, <strong>gradient_bg.xml</strong>:</p><pre><em>&lt;?</em><strong>xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;</strong><em>?&gt;<br></em>&lt;<strong>shape<br>    android:shape=&quot;rectangle&quot;<br>    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;</strong>&gt;<br><br>    &lt;<strong>corners android:radius=&quot;25dp&quot;</strong>/&gt;</pre><pre>    &lt;<strong>gradient<br>        android:type=&quot;linear&quot;<br>        android:angle=&quot;45&quot;<br>        android:startColor=&quot;@color/colorPrimaryDark&quot;<br>        android:endColor=&quot;@color/colorPrimary&quot;</strong>/&gt;<br>&lt;/<strong>shape</strong>&gt;</pre><p>Let’s give our TabLayout a nice outline by creating a drawable named<strong> tab_bg.xml:</strong></p><pre><em>&lt;?</em><strong>xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;</strong><em>?&gt;<br></em>&lt;<strong>shape android:shape=&quot;rectangle&quot;<br>    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;</strong>&gt;<br>    &lt;<strong>corners android:radius=&quot;25dp&quot;</strong>/&gt;</pre><pre>    &lt;<strong>stroke android:color=&quot;@color/colorPrimaryDark&quot; android:width=&quot;1dp&quot;</strong>/&gt;</pre><pre>    &lt;<strong>solid android:color=&quot;#00000000&quot;</strong>/&gt;<br><br>&lt;/<strong>shape</strong>&gt;</pre><p>And finally the layout of our activity,<strong> activity_main.xml</strong>:</p><pre><em>&lt;?</em><strong>xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;</strong><em>?&gt;<br></em>&lt;<strong>LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;<br>    xmlns:tools=&quot;http://schemas.android.com/tools&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;match_parent&quot;<br>    android:orientation=&quot;vertical&quot;<br>    tools:context=&quot;.MainActivity&quot;</strong>&gt;<br><br>    &lt;<strong>FrameLayout<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:padding=&quot;32dp&quot;<br>        android:clipToPadding=&quot;false&quot;</strong>&gt;<br><br>        &lt;<strong>View<br>            android:id=&quot;@+id/indicator&quot;<br>            android:layout_width=&quot;0dp&quot;<br>            android:layout_height=&quot;50dp&quot;<br>            android:background=&quot;@drawable/gradient_bg&quot;</strong>/&gt;<br><br>        &lt;<strong>android.support.design.widget.TabLayout<br>            android:id=&quot;@+id/tab&quot;<br>            android:layout_width=&quot;match_parent&quot;<br>            android:layout_height=&quot;50dp&quot;<br>            android:background=&quot;@drawable/tab_bg&quot;<br>            app:tabGravity=&quot;fill&quot;<br>            app:tabMode=&quot;fixed&quot;<br>            app:tabSelectedTextColor=&quot;#ffffff&quot;<br>            app:tabIndicatorColor=&quot;@null&quot;<br>            app:tabRippleColor=&quot;@null&quot;</strong>/&gt;<br><br>    &lt;/<strong>FrameLayout</strong>&gt;<br><br>    &lt;<strong>android.support.v4.view.ViewPager<br>        android:id=&quot;@+id/viewPager&quot;<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;match_parent&quot;</strong>/&gt;<br><br><br>&lt;/<strong>LinearLayout</strong>&gt;</pre><p>Note that the indicator’s layout_width is set to 0dp. We will assign it at runtime with the measured width of the TabLayout divided by number of tabs.</p><h3>Code</h3><p>Let’s start putting the pieces together. I have written simple FragmentPagerAdapter and Fragment classes to demonstrate that the custom indicator does follow scroll gestures:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/92b65d7bf7ba9ccbabb341434520fbe3/href">https://medium.com/media/92b65d7bf7ba9ccbabb341434520fbe3/href</a></iframe><p>And lastly the logic to determine the translation:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c98d8f24205ffccc924a95018d06198/href">https://medium.com/media/4c98d8f24205ffccc924a95018d06198/href</a></iframe><p>And here’s the output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/274/1*1hNxC6IdJVAgB6KFrrCNgQ.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/274/1*Q7fhawFbJcy4OKcmFVDWjA.gif" /><figcaption>Clicking on tab (left) and Sliding the viewpager (right)</figcaption></figure><p>I hope someone will find this useful and if you have any suggestions please leave a comment below. Happy coding! :)</p><p><a href="https://github.com/leovinsen/GradientTabs">leovinsen/GradientTabs</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd49c3a0f4f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>