# Building a Segmented Progress Bar in Android

DevFeed: [Building a Segmented Progress Bar in Android](<https://devfeed.tech/articles/building-a-segmented-progress-bar-in-android-23689.md>)

Original publisher: [Read original article](<https://medium.com/betclic-tech/building-a-segmented-progress-bar-in-android-e3f198db393d?source=rss----7e406d68d94b---4>)

Author: Stephen Vinouze

Published: 2021-11-30T15:24:34Z

Content type: tutorial

Language: en

Sources: [betclic-tech - Medium](<https://devfeed.tech/sources/betclic-tech-medium.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [Canvas](<https://devfeed.tech/topics/canvas.md>), [User Interfaces](<https://devfeed.tech/topics/user-interfaces.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [building](<https://devfeed.tech/tags/building.md>), [canvas](<https://devfeed.tech/tags/canvas.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [mobile-app-development](<https://devfeed.tech/tags/mobile-app-development.md>), [programming](<https://devfeed.tech/tags/programming.md>), [ui](<https://devfeed.tech/tags/ui.md>), [user-experience](<https://devfeed.tech/tags/user-experience.md>), [user-interfaces](<https://devfeed.tech/tags/user-interfaces.md>)

## AI overview

A tutorial on building a segmented progress bar in Android by creating a custom View and drawing the interface with Canvas, Paint, and Path objects. It introduces the progress bar's segmented shapes and animation, then begins with a simpler one-segment implementation and discusses avoiding object allocation inside onDraw().

## Source excerpt

Leverage the power of custom drawing.Photo by Daniel Cheung on Unsplash At Betclic, we've proudly released our first in-app metagaming experience. And believe me, it's a huge step forward in the sportsbook industry. Challenging our users on different betting situations and rewarding them instantly was unheard of amongst our competitors. To achieve this, we wanted to bring the best user experience possible to engage our users. Amongst many topics, we've worked on the progression experience. We decided to build an exciting progress bar to reward our users for their progression. When it comes to building user interfaces (UI), you'll often rely on available tools provided by the SDK. However, there are times when your UI requirements prevent you from using them. You may try to tweak your tools, but it just won't fit the bill. To give the wanted look and feel of this progress bar, we decided to draw it ourselves. It turns out it's not as complicated as one may think. Creating Your Custom View Imagine a painter in front of a whiteboard. He'll need a set of brushes along with paint buckets. In Android, the whiteboard would be the Canvas. To draw on it, you'll need Paint objects instead of brushes and paint buckets. Finally, you'll use Path objects to direct the painter's arm onto the Canvas. We can manipulate all of the objects above directly inside a View. More specifically, all the magic happens in the onDraw() callback. https://medium.com/media/edb134052a28bb1bdf476877ee1cd965/href Coming back to the progress bar, let's start by breaking it down. We have a set of quadrilaterals displaying different angles. They're spaced from each other and have a filled state without space. Finally, we have a wavy animation synchronized with its filling progress. Before trying to match all these requirements, we can start with a simpler version. Don't worry, though. We'll get to the bottom of it! Drawing a One-Segment Progress Bar The first step would be to draw its most basic version: