GithubHelp home page GithubHelp logo

neil-orzzh / materialprogressbar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zhanghai/materialprogressbar

0.0 1.0 0.0 2.75 MB

Material design ProgressBar with consistent appearance

Shell 0.16% Java 99.84%

materialprogressbar's Introduction

MaterialProgressBar

Icon

Material design ProgressBar with consistent appearance on Android 4.0+.

Screenshot

Android 4.4.4

Android 4.4.4

Samsung Android 5.0.1 (native implementation fails to tint)

Samsung Android 5.0.1

Android 5.1.1

Android 5.1.1

Sample application APK

Integration

Gradle:

compile 'me.zhanghai.android.materialprogressbar:library:1.0.2'

Usage

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 HorizontalIndeterminateProgressDrawable on a ProgressBar.

progressBar.setIndeterminateDrawable(new HorizontalIndeterminateProgressDrawable(this));

In order to make your ProgressBar take the correct and consistent size on all versions, you need to use one of the styles this library provided. The trick inside it is android:minHeight, android:maxHeight (and width) that controls the Drawable size.

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

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 setShowTrack() and setUseIntrinsicPadding(). Tint-related methods setTint(), setTintList() and setTintMode() are also backported so that you can use them directly.

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

ProGuard

If you are using ProGuard, you need to add the following line to your ProGuard configuration file, so that ObjectAnimator can work properly.

-keep class me.zhanghai.android.materialprogressbar.** { *; }

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 Zhang Hai

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.

materialprogressbar's People

Contributors

zhanghai avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.