Giter Site home page Giter Site logo

static-progress-bar's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

static-progress-bar's Issues

setMaximumPercentage not working and text seems to be below the progress

I'm setting that value after the CustomProgress is created so it does nothing and gets the default value??

This is how I finally implemented the static progress bar:

my_activity.xml

ProgressBar
android:id="@+id/npsProgressBar"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="10dp"
android:gravity="center"
style="@style/CustomProgressBar"
android:layout_width="match_parent"
android:layout_height="@dimen/custom_progress_height"/>

styles.xml

<style name="CustomProgressBar" parent="android:Widget.ProgressBar.Horizontal">
    <item name="android:indeterminateOnly">false</item>
    <item name="android:progressDrawable">@drawable/custom_progress_bar</item>
    <item name="android:minHeight">10dip</item>
    <item name="android:maxHeight">20dip</item>
</style>

inside drawable folder: custom_progress_bar.xml

?xml version="1.0" encoding="UTF-8"?>
layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
item
android:id="@android:id/background">
shape>
padding
android:bottom="3dip"
android:top="3dip"
android:left="3dip"
android:right="3dip"
/>
corners
android:radius="5dip" />
gradient
android:startColor="@color/main_blue_light"
android:centerColor="@color/main_blue_light"
android:centerY="0.50"
android:endColor="@color/main_blue_light"
android:angle="270" />





corners
android:radius="5dip" />
gradient
android:startColor="@color/main_blue"
android:endColor="@color/main_blue"
android:angle="90" />



MyActivity.java

private int mProgressNpsStatus = 0;

@OverRide
protected void onCreate(Bundle savedInstanceState) {
...
npsProgressBar = (ProgressBar) findViewById(R.id.npsProgressBar);
animateNpsProgressBar();
}

//method to animate the progress
private void animateNpsProgressBar(){

    // Start lengthy operation in a background thread
    new Thread(new Runnable() {
        public void run() {
            while (mProgressNpsStatus < (int) 50) {
                mProgressNpsStatus += 1;
                // Update the progress bar
                mHandler.post(new Runnable() {
                    public void run() {
                        npsProgressBar.setProgress(mProgressNpsStatus);
                        npsNumberTextView.setText(mProgressNpsStatus + "%");
                    }
                });
                try {
                    //Display progress slowly
                    Thread.sleep(50);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }).start();
}

Change orientation error

When you change the orientation from landscape to portrait the screen doesn't refresh correctly. You should call resetWidth() in the initView() method.

How to set progress?

I'm sorry but i don't see how do I set the current progress or percentage for the progress bar, there is a setMaximun percentage and getCurrentPercentage but there is no setCurrentPercentage or setProgress method?.

Color Gradient

I love this class. I think it's so awesome and is my favorite progress bar so far. Few things:

  • getColor() is deprecated. Replace getResources().getColor( with ContextCompat.getColor(getContext(), in lines 75&76.
  1. Is there a way to introduce a color gradient to the Progress Bar so that the further the progress the stronger the progress bar's color becomes?

I thought about introducing a drawable layer-list like this but wasn't sure if I could do it since we're extending from a textView:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@android:id/Color">
        <shape>
            <corners android:radius="5dip" />
            <gradient
                android:angle="0"
                android:centerColor="@color/amber_500"
                android:centerY="0.5"
                android:endColor="@color/red_500"
                android:startColor="@color/green_500" />
        </shape>
    </item>
</layer-list>

Or using:

getPaint().setShader(new LinearGradient(0,0,0,textView.getLineHeight(), startColor, endColor, Shader.TileMode.REPEAT));

  1. setAlpha() line 130 is killing this object. Is there a way to bring the text to the front and have set the text and customprogress at their proper colors?

Loving this Progress Bar.

Consider creating a Gradle repository

Hey there,

This is a great library, but it would be useful if there was a Gradle repository so this lib can be integrated into an app with ease.

Thanks!

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.