Member-only story
Every Android Developer’s curiosity point
🌟Members can scroll down to enjoy! Non-members, click here for full access.🌟
Image our imaginary intern Curious Abhi, who has just started exploring custom views. As he scrolls through the code in his team’s app repo, something catches his eye:
😱 A new component ButtonWithProgressBar being used in a layout file
😱 Attribute like progressColor, buttonSize — crazy, unique, custom properties.
Curious Abhi digs deeper into the code, where he spots an unfamiliar piece: declare-styleable. As questions arise, he realises that understanding this might be the key to creating flexible, beautiful views and becoming a full time engineer.
And so, here’s a short guide that demystifies declare-styleable, its role in custom views, and how it can empower you and Curious Abhi to build more flexible UI components.
Goal: Creating a Button with a Progress Bar
Here’s the expectations for the custom button with a progress bar on top of it. When a user clicks the button, a progress bar should appear on top of the button, indicating a loading state. In this blog, we’ll use declare-styleable to define attributes for styling both the button and the progress bar, including colors, dimensions, and progress values.










