Giter Site home page Giter Site logo

materialish-progress's Introduction

Material-ish Progress

A material style progress wheel compatible with 2.3

I needed to keep a consistent (or as close as possible) look in an app across all Android Versions. The progress wheel is quite cool in Lollipop, and pretty horrible on Gingerbread.

So I created this. This view uses Progress Wheel as a base, but has been almost completely rewritten (the original view uses handlers for updating the wheel).

This is how it looks:

spinning wheel

Usage

You can create your own progress wheel in xml like this (remeber to add xmlns:wheel="http://schemas.android.com/apk/res-auto"):

<com.pnikosis.materialishprogress.ProgressWheel
        android:id="@+id/progress_wheel"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        wheel:barColor="#5588FF"
        wheel:progressIndeterminate="true" />

Or in code:

ProgressWheel wheel = new ProgressWheel(context);
wheel.setBarColor(Color.BLUE);
...

For making the wheel indeterminate, just call the spin() method. If you set a progress value, the whell will stop spinning.

You have two methods for setting the progress:

progressWheel.setProgress(float value)

Sets the value, and the wheel will smoothly animate to that value. The speed of the animation is defined by the spinSpeed (can be set with setSpinSpeed, which number is the number of full turns per second)

progressWheel.setProgressImmediate(float value)

Sets the value, and the wheel will instantly move to that value

Fill radius

In case you want the spinning wheel to fill the whole layout instead of having a fixed size, you can use fillRadius.

<com.pnikosis.materialishprogress.ProgressWheel
        android:id="@+id/progress_wheel"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        wheel:barColor="#5588FF"
        wheel:progressIndeterminate="true"
        wheel:fillRadius="true" />

This way, the wheel will be as big as the parent layout. Be warned though, if the parentlayout is not square, the wheel will become an oval.

License

Copyright 2014 Nico Hormazábal

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.

materialish-progress's People

Contributors

nico2sh 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.