Android view with both path from constructed path or from svg.

Overview

android-pathview

Gitter Android Arsenal Maven Central

You want to animate svg or normal Paths?<br> Change the color, pathWidth or add svg.<br> Animate the "procentage" property to make the animation.

There are two types of paths :

1. From Svg

<com.eftimoff.androipathview.PathView
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/pathView"
    android:layout_width="150dp"
    android:layout_height="150dp"
    app:pathColor="@android:color/white"
    app:svg="@raw/settings"
    app:pathWidth="5dp"/>

Result

svg

2. From Path

<com.eftimoff.androipathview.PathView
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/pathView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:pathColor="@android:color/white"
    app:pathWidth="3dp"/>

In Code

    final Path path = new Path();
        path.moveTo(0.0f, 0.0f);
        path.lineTo(length / 4f, 0.0f);
        path.lineTo(length, height / 2.0f);
        path.lineTo(length / 4f, height);
        path.lineTo(0.0f, height);
	    path.lineTo(length * 3f / 4f, height / 2f);
	    path.lineTo(0.0f, 0.0f);
	    path.close();
	
pathView.setPath(path);

Result

svg

Use the animator for parallel animation

    pathView.getPathAnimator()
        .delay(100)
        .duration(500)
        .listenerStart(new AnimationListenerStart())
        .listenerEnd(new AnimationListenerEnd())
        .interpolator(new AccelerateDecelerateInterpolator())
        .start();

Use the animator for sequential animation

    pathView.getSequentialPathAnimator()
        .delay(100)
        .duration(500)
        .listenerStart(new AnimationListenerStart())
        .listenerEnd(new AnimationListenerEnd())
        .interpolator(new AccelerateDecelerateInterpolator())
        .start();

If you want to use the svg colors.

    pathView.useNaturalColors();

If you want to draw the real SVG after the path animation.

It is in still in development.

    pathView.setFillAfter(true);

path

TODO

  1. Make persistent "percentage" field on orientation change.
Limitations

When working with SVGs you can not WRAP_CONTENT your views.

Used in apps

Message me if you want to be included in this list.

Thanks to
Contributors

I want to update this library and make it better. So any help will be appreciated. Make and pull - request and we can discuss it.

Download
dependencies {
	compile 'com.eftimoff:android-pathview:1.0.8@aar'
}
Changelog

1.0.8

[Fix] Removed not properly used android:allowBackup.

1.0.7

[Feature] Sequential path animation.
[Fix] Use dimensions instead of float for pathWidth.
Licence
Copyright 2016 Georgi Eftimov

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.
Comments
  • When I use getSequentialPathAnimator (), draw a lot of extra lines

    When I use getSequentialPathAnimator (), draw a lot of extra lines

    image Like the one shown above ,When I use the code below, it happens.

         pathView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
    //                pathView.getPathAnimator().
                    pathView.getSequentialPathAnimator().
                            delay(100).
                            duration(5000).
                            interpolator(new AccelerateDecelerateInterpolator()).
                            start();
    
    bug 
    opened by MartinHY 9
  • Why the white line doesn't show?

    Why the white line doesn't show?

    In my own machine ,it works just fine,but in my colleague's machine ,the white line doesn't show?We share the same code.Could you please tell me why? qq 20150803121457 qq 20150803121530

    bug question 
    opened by THEONE10211024 8
  • help me! why ?

    help me! why ?

    dependencies{ compile 'com.eftimoff:android-pathview:1.0.6@aar' }

    <com.eftimoff.androipathview.PathView
        android:id="@+id/pathView"
        android:layout_width="150dp"
        android:layout_height="150dp"
        app:pathColor="@android:color/white"
        app:pathWidth="10"
        app:svg="@raw/settings"/>
    

    in activity xml , running but no find

    opened by tosslife 5
  • stroke-linecap is being ignored

    stroke-linecap is being ignored

    Hi,

    I am trying to draw a path, smth like an arch with rounded corners, however "stroke-linecap" parameter seems to be skipped and so the result image is without rounded corners.

    svg example:

    layout: <com.eftimoff.androipathview.PathView xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/archLeftPathView" android:layout_width="180dp" android:layout_height="180dp" app:pathColor="@android:color/white" app:svg="@raw/arc_left" app:pathWidth="60"/>

    may be I am missing smth?

    You can verify the svg using smth like http://www.rapidtables.com/web/tools/svg-viewer-editor.htm

    bug enhancement done 
    opened by casper1149 4
  • setting fillAfter or fill in PathView tag

    setting fillAfter or fill in PathView tag

    Hi First I should say thanks for your awesome library . If there was a property in PathView tag something like app:fillAfter="true" or app:fill="true" would be very useful , because some times we need to use it as a special SVG image view for just showing whole image without animation , I know there is some libraries for showing SVG images out there , but it would be good to have just one library that can animate SVG images and also showing them statically . For now I'm doing it by writing PathView.setFillAfter(true); in code and setting animation duration to 1 for showing it immediately , but you know it's a little dirty :P Also if you like I can help you in making these changes in code to merge with master branch.

    enhancement 
    opened by mobi-life 3
  • why i can't addCircle to the path ?

    why i can't addCircle to the path ?

    hi,

    when i add Circle to the path using this code : path.addCircle(width/2,width/2,width-padding, Path.Direction.CW);

    pathview make Circle is not shown

    question 
    opened by tarek360 3
  • Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 2124 (SVG Loader)

    Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 2124 (SVG Loader)

    The sample project crashes with an internal platform error (no stacktrace). Crashes on devices from API 14 till API 19, different device models, emulated and physical devices as well. Works on API 19 and above.

    bug done 
    opened by mradzinski 3
  • Attempt to invoke virtual method 'android.graphics.RectF com.caverock.androidsvg.SVG.getDocumentViewBox()' on a null object reference

    Attempt to invoke virtual method 'android.graphics.RectF com.caverock.androidsvg.SVG.getDocumentViewBox()' on a null object reference

    I have an error which crash app: Attempt to invoke virtual method 'android.graphics.RectF com.caverock.androidsvg.SVG.getDocumentViewBox()' on a null object reference

    Bug occurs on tablet with tegra 2 and phones with Mediatek.

    Full error log:

    java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.RectF com.caverock.androidsvg.SVG.getDocumentViewBox()' on a null object reference at com.eftimoff.androipathview.SvgUtils.rescaleCanvas(SvgUtils.java:129) at com.eftimoff.androipathview.SvgUtils.drawSvgAfter(SvgUtils.java:76) at com.eftimoff.androipathview.PathView.fillAfter(PathView.java:216) at com.eftimoff.androipathview.PathView.onDraw(PathView.java:204) at android.view.View.draw(View.java:15231) at android.view.View.updateDisplayListIfDirty(View.java:14167) at android.view.View.getDisplayList(View.java:14189) at android.view.View.draw(View.java:14959) at android.view.ViewGroup.drawChild(ViewGroup.java:3405) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198) at android.view.View.draw(View.java:15234) at android.view.View.updateDisplayListIfDirty(View.java:14167) at android.view.View.getDisplayList(View.java:14189) at android.view.View.draw(View.java:14959) at android.view.ViewGroup.drawChild(ViewGroup.java:3405) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198) at android.view.View.updateDisplayListIfDirty(View.java:14162) at android.view.View.getDisplayList(View.java:14189) at android.view.View.draw(View.java:14959) at android.view.ViewGroup.drawChild(ViewGroup.java:3405) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198) at android.view.View.updateDisplayListIfDirty(View.java:14162) at android.view.View.getDisplayList(View.java:14189) at android.view.View.draw(View.java:14959) at android.view.ViewGroup.drawChild(ViewGroup.java:3405) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198) at android.view.View.updateDisplayListIfDirty(View.java:14162) at android.view.View.getDisplayList(View.java:14189) at android.view.View.draw(View.java:14959) at android.view.ViewGroup.drawChild(ViewGroup.java:3405) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198) at android.view.View.updateDisplayListIfDirty(View.java:14162) at android.view.View.getDisplayList(View.java:14189) at android.view.View.draw(View.java:14959) at android.view.ViewGroup.drawChild(ViewGroup.java:3405) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198) at android.view.View.draw(View.java:15234) at android.widget.FrameLayout.draw(FrameLayout.java:598) at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2650) at android.view.View.updateDisplayListIfDirty(View.java:14167) at android.view.View.getDisplayList(View.java:14189) at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:273) at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:279) at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:318) at android.view.ViewRootImpl.draw(ViewRootImpl.java:2530) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2352) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1982) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5885) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767) at android.view.Choreographer.doCallbacks(Choreographer.java:580) at android.view.Choreographer.doFrame(Choreographer.java:550) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5296) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

    bug 
    opened by b3stia 2
  • which tool you use to generate svg file ?

    which tool you use to generate svg file ?

    use the svg file that I generated having a problem :

    com.caverock.androidsvg.SVGParseException: SVG parse error: At line 2, column 51: syntax error at com.caverock.androidsvg.SVGParser.parse(SVGParser.java:611) at com.caverock.androidsvg.SVG.getFromResource(SVG.java:187) at com.caverock.androidsvg.SVG.getFromResource(SVG.java:172) at com.eftimoff.androipathview.SvgUtils.load(SvgUtils.java:60) at com.eftimoff.androipathview.PathView$1.run(PathView.java:242) at java.lang.Thread.run(Thread.java:818) Caused by: org.apache.harmony.xml.ExpatParser$ParseException: At line 2, column 51: syntax error at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:515) at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:474) at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:316) at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:279) at com.caverock.androidsvg.SVGParser.parse(SVGParser.java:599) at com.caverock.androidsvg.SVG.getFromResource(SVG.java:187)  at com.caverock.androidsvg.SVG.getFromResource(SVG.java:172)  at com.eftimoff.androipathview.SvgUtils.load(SvgUtils.java:60)  at com.eftimoff.androipathview.PathView$1.run(PathView.java:242)  at java.lang.Thread.run(Thread.java:818) 

    opened by yanxinmiao 1
  • How to do reversed animation?

    How to do reversed animation?

    I mean animate from drawn state to erased state. Actually, I want to do cyclic animation for progress loader, which will be animate painting then animate erasing then again painting and then erasing and so on... Could you give me a hint how to do it ?

    opened by lion4ik 1
  • fill , fillColor and naturalColors attributes added

    fill , fillColor and naturalColors attributes added

    • Showing svg statically (fill) even without animation as a vector image view
    • The ability to setting solid color (fillColor) for svg
    • The ability to setting natural color for drawing path from layout xml (naturalColor)
    • Adding dependency to com.nineoldandroids for supporting path animation in old devices < 14
    opened by mobi-life 1
  • divide by zero

    divide by zero

    hi, thank for this great library but I have a problem I get this error when I'm trying to run it my splash activity

    here is the error : 02-02 14:24:17.101 15421-15421/? E/AndroidRuntime: FATAL EXCEPTION: main Process: telegram.abdi.messangerbot, PID: 15421 java.lang.RuntimeException: Unable to start activity ComponentInfo{telegram.abdi.messangerbot/telegram.abdi.messangerbot.Activities.SplashActivity}: java.lang.ArithmeticException: divide by zero at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2666) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6121) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779) Caused by: java.lang.ArithmeticException: divide by zero at com.eftimoff.androipathview.PathView$AnimatorSetBuilder.duration(PathView.java:620) at telegram.abdi.messangerbot.Activities.SplashActivity.onCreate(SplashActivity.java:35) at android.app.Activity.performCreate(Activity.java:6723) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2619)

    and here is my code : splash_view.setSvgResource(R.drawable.ic_splash_bot); splash_view.getSequentialPathAnimator() .delay(500) .duration(500) .listenerStart(new StartListener()) .listenerEnd(new EndListener()) .interpolator(new AccelerateDecelerateInterpolator()) .start(); splash_view.useNaturalColors(); splash_view.setFillAfter(true);

    opened by moeindev 1
  • Warning:com.caverock.androidsvg.SVGImageView: can't find referenced class com.caverock.androidsvg.R$styleable

    Warning:com.caverock.androidsvg.SVGImageView: can't find referenced class com.caverock.androidsvg.R$styleable

    Warning:com.caverock.androidsvg.SVGImageView: can't find referenced class com.caverock.androidsvg.R$styleable

    When creating a release build. I mean progaurd is removing this class

    bug 
    opened by john1jan 2
  • Crash on Battery Saver Mode

    Crash on Battery Saver Mode

    Hi, Once you have the project configured and running, It crashes when the phone is in Battery saving mode [android 5.1 ], Tested it on device Moto E 1st Gen android.

    bug help wanted 
    opened by hiteshdua1 10
Releases(1.0.8)
Owner
Georgi Eftimov
Android developer
Georgi Eftimov
PaintableVectorView enables to change color of paths/groups in Vector Drawable (SVG)

PaintableVectorView PaintableVectorView enables to change color of paths/groups in Vector Drawable (SVG) Demo Car icon made by Prosymbols from www.fla

Jakub Anioła 164 Dec 16, 2022
This a demo application with animated SVG animation of Smiley

Animated-Smiley-Rating Animated Customer feedback and rating UI ?? License Copyright 2021 Aiman Muzafar Licensed under the Apache License, Version 2.0

Aiman Muzafar 12 Aug 12, 2021
💪 Rich Android Path. 🤡 Draw as you want. 🎉 Animate much as you can.

?? Rich Android Path. ?? Draw as you want. ?? Animate much as you can. Download sample app: Features Full Animation Control on Paths and VectorDrawabl

Ahmed Tarek 2.3k Dec 20, 2022
A view pager indicator view to deal with a large amount of pages.

Attention I'm not going to support this anymore. Just use a better solution, e.g. this one Indefinite-Pager-Indicator BubblePagerIndicator A view page

Bogdan Kornev 134 Aug 18, 2022
💳 Bank Card View is a simple and elegant card view with Flip animation.

Visualização de cartão bancário ?? Bank Card View é uma visualização de cartão simples e elegante com animação Flip. Versões Selecione a língua : Engl

Geovani Amaral 10 Dec 12, 2022
💳 Bank Card View is a simple and elegant card view with Flip animation.

Visualização de cartão bancário ?? Bank Card View é uma visualização de cartão simples e elegante com animação Flip. Versões Selecione a língua : Engl

Geovani Amaral 9 Aug 26, 2022
Deprecated in favour of https://developer.android.com/reference/android/support/v4/view/animation/PathInterpolatorCompat.html

Deprecated: use https://developer.android.com/reference/android/support/v4/view/animation/PathInterpolatorCompat.html instead. android-cubic-bezier-in

Codesoup 161 Jan 1, 2023
Android view inspired by http://qrohlf.com/trianglify/

Trianglify Android view inspired by http://qrohlf.com/trianglify/ Usage Add the dependency dependencies { compile 'com.manolovn:trianglify:1.1.0'

Manuel Vera 457 Dec 15, 2022
An easy, flexible way to add a shimmering effect to any view in an Android app.

Shimmer for Android Shimmer is an Android library that provides an easy way to add a shimmer effect to any view in your Android app. It is useful as a

Facebook 5.1k Dec 26, 2022
A simple animated step view for Android

StepView A simple animated step view for Android. Backward and forward animations is supported. Usage Add jcenter() to repositories block in your grad

Bogdan Kornev 833 Dec 30, 2022
Animation View to Highlight particular Views 🎯 for Android

TargetView Animation View to Highlight particular Views ?? for Android, it can be Used with Views that you see important (Like CountDownTimer), And al

Anas Altair 53 Aug 7, 2021
Android animated recording view

AnimatedRecordingView Android animated recording view .中文版 Preview Gradle compile 'com.haozhang.libary:android-animated-recording-view:1.0' How to use

Hand Zhang 348 Nov 16, 2022
Android Library to create Lottie animation view dialog easily with a lot of customization

LottieDialog Android Library to create Lottie animation view dialog easily with a lot of customization Why you should use Lottie Dialog You have no li

Amr Hesham 39 Oct 7, 2022
Android Library to create Lottie animation view dialog easily with a lot of customization

Android Library to create Lottie animation view dialog easily with a lot of customization

Amr Hesham 39 Oct 7, 2022
Cute view animation collection.

Android View Animations One day, I saw an iOS library, which is a view shaker, it's very beautiful. I think Android also need one, and should be bette

代码家 12.2k Jan 1, 2023
ViewAnimator view with a lollipop style reveal effect

ViewRevealAnimator Widget ViewAnimator view with a lollipop style reveal effect. Regular animation can be set (just like the default ViewAnimator) for

Alessandro Crugnola 339 Jun 3, 2022
🌠 Transform into a different view or activity using morphing animations.

TransformationLayout ?? Transform into a different view or activity using morphing animations. Using Transformation motions of new material version. D

Jaewoong Eum 2k Jan 3, 2023
💳 A quick and easy flip view through which you can create views with two sides like credit cards, poker cards etc.

The article on how this library was created is now published. You can read it on this link here. →. ?? EasyFlipView Built with ❤︎ by Wajahat Karim and

Wajahat Karim 1.3k Dec 14, 2022
Automatically manipulates the duration of animations dependent on view count. Quicksand .. the more you struggle.

QuickSand When showing a really enchanting explanatory animation to your users, but you know that after a while it'll get tedious and would stop users

Paul Blundell 385 Sep 9, 2022