Progress Button

A custom progress indicator with a tiny footprint for Android

Introduction

ProgressButton is a custom progress indicator with a tiny footprint. The default implementation provides a pin progress button as seen on the Android design site.

States

Sample application screenshot.

Usage

XML

Simply define ProgressButton in your layout files.

<com.f2prateek.progressbutton.ProgressButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

Java

Instantiate an instance of ProgressButton with a context.

ProgressButton button = new ProgressButton(context);

Customize

ProgressButton is highly customizable. You can supply your own resources to style it and give it a unique look. As a subclass of CompoundButton, you can use any if those attributes as well. Custom attributes defined for ProgressButton include:

  • progress : The current progress to display as an int
  • max : The maximum progress that can be displayed an int
  • circleColor : The color to display the progress background
  • progressColor : The color to indicate the progress
  • pinnedDrawable : Drawable displayed when the button is unpinned
  • unpinnedDrawable : Drawable displayed when the button is pinned
  • shadowDrawable : Drawable that acts as the shadow of the button
  • innerSize : Area inside the view that should be filled with the progressColor
  • animating : boolean start the button in an animating mode
  • animationStripWidth : Width of the animation bar
  • animationSpeed : The progress with which each frame of the animation appears to 'jump'
  • animationDelay : Delay before each animation frame.
  • pinned : Whether the button is pinned or not

Look under the /samples folder to see an example of how to use these attributes. The corresponding app is available on the Play Store.

Download

The source code to ProgressButton, its samples, and this website is available on GitHub.

Maven

<dependency>
    <groupId>com.f2prateek.progressbutton</groupId>
    <artifactId>progressbutton</artifactId>
    <version>(insert latest version)</version>
</dependency>

Gradle

compile 'com.f2prateek.progressbutton:progressbutton:(insert latest version)@aar'

Contributing

If you would like to contribute code you can do so through GitHub by forking the repository and sending a pull request.

When submitting code, please make every effort to follow existing conventions and style in order to keep the code as readable as possible. Please also make sure your code compiles by running mvn clean verify.

License

Copyright 2013 Prateek Srivastava
Copyright 2012 Roman Nurik

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.