vipulyaara / UberStyledProgressBarAndroid

New Uber styled progress bar created using Animated Vector Drawables.

Home Page:www.designabc.xyz

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UberStyledProgressBarAndroid

uber_11

A very simple Progress bar done with the almighty Animated Vector Drawable.

You need only three properties to make the animation work:

trimPathOffset is used to make path translate from 0 to 1
trimPathStart means cut the line from start
trimPathEnd means cut the line from end

Practically you only need files vd_line.xml and avd_line.xml in drawables to make it work. Set avd_line as background to any view and boom! You have your progress bar.


**Repeating the animation infinitely**

To repeat the animation infinitely after Lollipop (v21)
        final AnimatedVectorDrawable avd = (AnimatedVectorDrawable) ivNoTrip.getDrawable();
        avd.registerAnimationCallback(new Animatable2.AnimationCallback() {
            @Override
            public void onAnimationEnd(Drawable drawable) {
                avd.start();
            }
        });

But this approach does not work with AnimatedVectorDrawableCompat. So for backward compatibility, use this workaround

Runnable action = new Runnable() {
        @Override
        public void run() {
            repeatAnimation();
        }
    };

    private void initializeAvd() {
        avdProgress = AnimatedVectorDrawableCompat.create(context, R.drawable.avd_line);
        ivProgress = (ImageView) findViewById(R.id.iv_progress);
        ivProgress.setBackground(avdProgress);
        repeatAnimation();
    }

    private void repeatAnimation() {
        avdProgress.start();
        ivProgress.postDelayed(action, 1000); // Will repeat animation in every 1 second
    }



License

Copyright 2017 Vipul Kumar

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.

About

New Uber styled progress bar created using Animated Vector Drawables.

www.designabc.xyz

License:Other


Languages

Language:Java 100.0%