• Stars
    star
    2,215
  • Rank 20,817 (Top 0.5 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Material Design ProgressBar with consistent appearance

MaterialProgressBar

Icon

Material Design ProgressBar with consistent appearance on Android 4.0+.

Why MaterialProgressBar?

  • Consistent appearance on Android 4.0+.
  • Correct tinting across platforms.
  • Able to remove the intrinsic padding of framework ProgressBar.
  • Able to hide the progress background of framework horizontal ProgressBar.
  • Able to show a determinate circular progress.
  • Used as a drop-in replacement for framework ProgressBar.

Preview

Google Play

Sample APK

Android 4.4.4

Android 4.4.4

Samsung Android 5.0.1 (native implementation fails to tint)

Samsung Android 5.0.1

Android 6.0.1

Android 6.0.1

Integration

Gradle:

implementation 'me.zhanghai.android.materialprogressbar:library:1.6.1'

Usage

You can either simply use the MaterialProgressBar widget, or set drawables from this library on a regular ProgressBar.

Using Widget

Simply replace your ProgressBar with MaterialProgressBar, and remember to apply corresponding style and attribute for correct behavior.

For example, to create an indeterminate horizontal MaterialProgressBar:

<me.zhanghai.android.materialprogressbar.MaterialProgressBar
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:indeterminate="true"
    app:mpb_progressStyle="horizontal"
    style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal" />

In order to make your ProgressBar take the correct and consistent size on all versions, you will always need to use one of the styles from this library. The trick inside it is android:minWidth, android:maxWidth (and height) that controls the drawable size.

  • Widget.MaterialProgressBar.ProgressBar
  • Widget.MaterialProgressBar.ProgressBar.Horizontal
  • And more size and no-padding variants in styles.xml

Available custom attributes:

  • app:mpb_progressStyle: Style of progress drawable: circular or horizontal. Defaults to circular.
  • app:mpb_setBothDrawables: Whether both determinate and indeterminate drawables should be set on this progress bar. Defaults to false (for performance). Should be set to true if you want to use both of the backported determinate and indeterminate drawables.
  • app:mpb_useIntrinsicPadding: Whether progress drawable should use its intrinsic padding. Defaults to true.
  • app:mpb_showProgressBackground: Whether progress drawable should show a progress background. Defaults to true for horizontal progress drawable, false otherwise.
  • app:mpb_determinateCircularProgressStyle: Style of determinate circular progress drawable: normal or dynamic. Defaults to normal.

8 tint-related attributes such as app:mpb_progressTint and app:mpb_progressTintMode are also supported so that they can control the tinting of progress drawables. The default tint color is ?colorControlActivated, and the default tint mode is src_in.

For a detailed example, you can refer to the sample app's layout, where you can find examples such as removing progress padding or background.

Using Drawable

Three Material Design drawables are backported to Android 4.0 (API 14), so you can create one and set it directly on your ProgressBar.

For example, to set a IndeterminateHorizontalProgressDrawable on a ProgressBar.

progressBar.setIndeterminateDrawable(new IndeterminateHorizontalProgressDrawable(this));

You will also need to set a style from this library as in the section above.

For example, to define an indeterminate horizontal ProgressBar.

<ProgressBar
            android:id="@+id/indeterminate_horizontal_progress"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:indeterminate="true"
            style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal" />

Don't forget to create and set the drawable as above.

You can also customize the behavior of these drawables by calling setShowBackground() and setUseIntrinsicPadding(). Tint-related methods setTint(), setTintList() and setTintMode() are also backported so that you can use them directly, but remember to take these drawables as their actual type or TintableDrawable because VM won't be able to find these methods on Drawable for legacy platforms.

If you want to support API level < 18, you'll need to workaround a canvas limitation as in here; Using MaterialProgressBar does this automatically.

For a detailed example, you can refer to the onCreate() method of the old sample's MainActivity and its layout main_activity.xml.

ProGuard

The AAR of this library has already included a ProGuard configuration file to make ObjectAnimator work properly.

Older versions

Neither Support v4 nor AppCompat v7 backported animation API to versions prior to ICS, and the NineOldAndroids library has already been deprecated since people should all be using minSdkVersion="14" now, so versions older than ICS are not supported.

License

Copyright 2015 Hai Zhang

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.

More Repositories

1

MaterialFiles

Material Design file manager for Android
Kotlin
5,968
star
2

Douya

开源的 Material Design 豆瓣客户端(A Material Design app for douban.com)
Java
4,548
star
3

MaterialRatingBar

Material Design RatingBar with better appearance
Java
1,961
star
4

MaterialColdStart

Utilize the window background during cold start time to make your app look faster.
Shell
1,225
star
5

AndroidFastScroll

Fast scroll for Android RecyclerView and more
Java
701
star
6

PatternLock

Material Design Pattern Lock with auth flow implementation
Java
689
star
7

CustomTabsHelper

Custom tabs, made easy.
Java
386
star
8

Untracker

App to help you remove tracking information before sharing links
Kotlin
366
star
9

ComposePreference

Preference implementation for Jetpack Compose Material 3
Kotlin
182
star
10

archexp

浙江大学计算机体系结构课程实验
Verilog
166
star
11

AppIconLoader

Android app icon loader from AOSP iconloaderlib
Java
162
star
12

MaterialEditText

Material Design EditText with a delightful linear ripple in background
Java
146
star
13

zju-csse-undergraduate-design-latex-template

浙江大学计算机科学与技术、软件工程专业本科毕业设计 LaTeX 模板
TeX
138
star
14

SystemUiHelper

Helper for dealing with Android System UI visibility
Java
117
star
15

BeeShell

Java REPL on Android with BeanShell
Kotlin
107
star
16

EffortlessPermissions

An Android permission library extending Google's EasyPermissions with convenient additions.
Java
86
star
17

TextSelectionWebSearch

Add web search to text selection toolbar on Android
Java
84
star
18

gnome-shell-extension-transparent-top-bar

GNOME Shell extension that brings back the transparent top bar when free-floating in GNOME Shell 3.32
JavaScript
77
star
19

DouyaApiKey

豆芽 API Key 设置向导
Java
69
star
20

DoubanYearProgress

Year progress for Douban
JavaScript
63
star
21

AndroidUtil

Utilities to make the life of an Android developer easier
Java
59
star
22

libarchive-android

libarchive as an Android library
C
56
star
23

AndroidSVGScripts

Bash scripts to automate and extend the process of using SVG as Android image asset
Shell
56
star
24

AndroidRetroFile

Backport of java.nio.file API (JSR 203) for Android
Java
47
star
25

mipsasm

MIPS assembler and IDE
Java
46
star
26

MaterialPlayPauseDrawable

Material Design play/pause Drawable with animation
Java
37
star
27

libselinux-android

libselinux as an Android library
C
24
star
28

join-screenshots.zhanghai.me

Join screenshots with HTML5
HTML
23
star
29

opengl-c-solarsystem

Animated solar system model implemented with OpenGL and FreeGLUT in C
C
22
star
30

orgexp

Computer Organization Experiment, Shi Qingsong, Zhejiang University.
Verilog
21
star
31

pykeymacs

Emacs style keyboard macros implemented in Python
Python
20
star
32

vntools

Tools for working with visual novels
C++
18
star
33

filesystem-kt

Multiplatform Kotlin library for accessing files and file systems
Kotlin
17
star
34

deadbeef-gnome-mmkeys

Add GNOME multimedia keys support in DeadBeef player using DBus
C
16
star
35

collision-detection-bubbles

A collision detection and resolution experiment with Two.js
JavaScript
16
star
36

gtkmmproject

Gtkmm CLion Project
CMake
12
star
37

linenoise-android

Linenoise as an Android library
C
12
star
38

qt5project

Qt 5 CLion project
C++
10
star
39

Reflected

Java library for easy-to-use reflection
Java
9
star
40

AndroidLibraryTemplate

Android library template
9
star
41

SeekBarPreference

A Preference that shows a dialog with a SeekBar widget.
Java
9
star
42

Bytecoder

Android gradle plugin to generate bytecode for accessing any method or field
Java
9
star
43

Functional

Java library for JavaScript-like functional methods
Java
8
star
44

zhsh

A minimal interactive shell written in C.
C
8
star
45

DouyaCiBuilds

豆芽 CI 构建版本仓库
8
star
46

Palette

Sample application to showcase android.support.v7.graphics.Palette
Java
6
star
47

twitter-unwanted-follower-remover

Semi-automatic command line tool for removing unwanted followers on Twitter
JavaScript
5
star
48

particle-system-campfire

A particle system experiment with Two.js
HTML
5
star
49

AimBackend

Another Instant Messager app, backend.
JavaScript
5
star
50

AimAndroid

Another Instant Messager app, Android.
Java
5
star
51

kiscript

ECMAScript, kept simple.
C
5
star
52

ColorPicker

Android color picker from AOSP
Java
5
star
53

markdown-template

Zhang Hai's markdown template
JavaScript
4
star
54

gnome-shell-extension-es6-class-codemod

A jscodeshift transform that helps migrating GNOME Shell extensions to 3.32
JavaScript
4
star
55

Promise

Java library for JavaScript-like Promise
Java
4
star
56

ZJUWLANAutoLogin

A chrome extesion that enables auto login when redirected to login page on ZJUWLAN
JavaScript
4
star
57

resume.zhanghai.me

Zhang Hai's resume
HTML
4
star
58

gettext-po-parser

Gettext PO file parser
4
star
59

xkeymacs

X11 KEYboard MACroS
C
4
star
60

fpga-life-game

Conway's game of life implemented on FPGA with combinational logic
Verilog
3
star
61

zhclib

A C library written by me
C
3
star
62

translations.zhanghai.me

Search translations in open source projects
HTML
3
star
63

stone.zhanghai.me

(Zhang Hai's) The story of the stone
HTML
3
star
64

douya-website

Source of Zhang Hai's Douya project home
JavaScript
3
star
65

SsidTester

SSID tester for identifying ZJUWLAN difficulty. Also serves as a sample application for beginners.
Java
3
star
66

course_linux_programming

Linux programming course
C
3
star
67

zh-conf-backup

Backup script for Zhang Hai's configuration
Shell
3
star
68

Labyrinth

Labyrinth game with OpenGL
Java
3
star
69

resume-legacy

Source of Zhang Hai's resume, legacy version
CSS
2
star
70

slides.zhanghai.me

Zhang Hai's slides
HTML
2
star
71

douya.zhanghai.me

Zhang Hai's Douya
ApacheConf
2
star
72

api-functions-worth-calling

API - Functions worth calling
HTML
2
star
73

optical-system-mfc

Optical System with MFC
C
2
star
74

ExpressionEvaluator

Expression evaluator written in Java
Java
2
star
75

AimFrontend

Another Instant Messager app, frontend.
Vue
2
star
76

zh-minecraft-saves

My Minecraft saves.
Shell
2
star
77

FxPaint

Paint app written with JavaFx
Java
2
star
78

projects.zhanghai.me

Zhang Hai's projects
HTML
2
star
79

calc

C Topic Project - A calculator based on operator precedence
C
2
star
80

www.zhanghai.me

Zhang Hai's main site
HTML
2
star
81

aoe4-mod-superweapon-pvp

Add Siege Camp in campaign as a superweapon for the game (PvP version)
1
star
82

lms

C Topic Project - A simple Library Management System
C
1
star
83

SePolicyInject

Android library to inject rules into binary SELinux kernel policies
CMake
1
star
84

DataStructure

An object oriented implementation of fundamental data structures (and algorithms) using C++11
C++
1
star
85

WordList

A simple android application to display specially annotated English word lists
Java
1
star
86

optical-system-qt

Optical System with Qt
C
1
star
87

seafile-server-github-actions-build

Seafile Server built by GitHub Actions
1
star
88

reveal-md-template

Reveal.js template with reveal-md
Makefile
1
star
89

reveal-js-template

Zhang Hai's reveal.js template
Shell
1
star
90

ShowcaseView

A fork from legacy branch of https://github.com/amlcurran/ShowcaseView
Java
1
star
91

blog.zhanghai.me

Zhang Hai's blog
HTML
1
star
92

sevenzipjbind

Mirrored from git://sevenzipjbind.git.sourceforge.net/gitroot/sevenzipjbind/sevenzipjbind
C++
1
star
93

translations-index.zhanghai.me

Translations index
1
star
94

abnf-kt

ABNF parser generator for Kotlin
Kotlin
1
star