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
TileView is a subclass of android.view.ViewGroup that asynchronously displays, pans and zooms tile-based images. Plugins are available for features like markers, hotspots, and path drawing.

This project isn't maintained anymore. It is now recommended to use https://github.com/peterLaurence/MapView. MapView is maintained by Peter, one of o

Mike Dunn 1.5k Dec 29, 2022
Android-ScrollBarPanel allows to attach a View to a scroll indicator like it's done in Path 2.0

Path 2.0 like ScrollBarPanel for Android Android-ScrollBarPanel allows to attach a View to a scroll indicator like it's done in Path 2.0. Features Sup

Arnaud Vallat 551 Dec 22, 2022
Animated SVG Drawing for Android

AnimatedSvgView Animated SVG Drawing for Android Usage Get SVG path data and add it to a string array: <string-array name="google_glyph_strings"> <i

Jared Rummler 2k Dec 12, 2022
An Android application which visualizes some of the famous Algorithms for finding path from Source to Destination in a 2D grid.

Pathfinding-Visualizer An Android application which visualizes some of the famous Algorithms for finding path from Source to destination in a 2D grid.

Pranjal Mishra 37 Aug 8, 2022
Path like scrollbar panel with clock.

ScrollBarPanelWithClock Path 2.0 like scrollbar with clock widget for Android. This is an open source library which uses the scroll bar library. I hav

learnNcode 170 Feb 20, 2021
Android View for displaying and selecting values in a circle-shaped View, with animations and touch gestures.

CircleDisplay Android View for displaying and selecting (by touch) values / percentages in a circle-shaped View, with animations. Features Core featur

Philipp Jahoda 287 Nov 18, 2022
FloatingView can make the target view floating above the anchor view with cool animation

FloatingView FloatingView can make the target view floating above the anchor view with cool animation Links 中文版 README Blog about FloatingView demo.ap

UFreedom 1.8k Dec 27, 2022
TourGuide is an Android library that aims to provide an easy way to add pointers with animations over a desired Android View

TourGuide TourGuide is an Android library. It lets you add pointer, overlay and tooltip easily, guiding users on how to use your app. Refer to the exa

Tan Jun Rong 2.6k Jan 5, 2023
View that imitates Ripple Effect on click which was introduced in Android L (for Android 2.3+)

RippleView View that imitates Ripple Effect on click which was introduced in Android L. Usage For a working implementation, Have a look at the Sample

Muthuramakrishnan Viswanathan 1.2k Dec 30, 2022
Snake View is a simple and animated linear chart for Android.

Snake View Snake library is a simple and animation line chart for Android. Latest Version How to use Configuring your project dependencies Add the lib

Txus Ballesteros 339 Dec 14, 2022
[] A simple way to "badge" any given Android view at runtime without having to cater for it in layout

Android ViewBadger A simple way to "badge" any given Android view at runtime without having to cater for it in layout. Note: If your aim is to replica

Jeff Gilfelt 3k Nov 28, 2022
A horizontal view scroller library for Android

View Flow for Android ViewFlow is an Android UI widget providing a horizontally scrollable ViewGroup with items populated from an Adapter. Scroll down

Patrik Åkerfeldt 1.8k Dec 29, 2022
A cool Open Source CoverFlow view for Android with several fancy effects.

FancyCoverFlow THIS PROJECT IS NO LONGER MAINTAINED! What is FancyCoverFlow? FancyCoverFlow is a flexible Android widget providing out of the box view

David Schreiber-Ranner 1.1k Nov 10, 2022
A simple, customizable and easy to use swipeable view stack for Android.

SwipeStack A simple, customizable and easy to use swipeable view stack for Android. QuickStart Include the Gradle dependency dependencies { compil

Frederik Schweiger 1.5k Dec 30, 2022
Custom android music player view.

InteractivePlayerView Custom android music player view. Screen Check it on youtube Usage(XML) Define it in your xml file. <co.mobiwise.library.Intera

Mert Şimşek 744 Dec 25, 2022
Shadow layout, shadow view for android.

ShadowViewHelper Shadow layout, shadow view for android. How to use: It's very simple to use. Gradle(Check newest version): compile 'com.github.wangji

WangJie 777 Dec 30, 2022
Android Quilt View Library

QuiltViewLibrary QuiltView displays views of different sizes in a scrollable grid. Dependencies This library depends on gridlayout_v7 ([email protected]:

Jacob Moncur 561 Nov 20, 2022
A velocimeter View for Android

Velocimeter A velocimeter View for Android Sample video: Youtube Velocimeter video Sample app: How to use Default colors <com.github.glomadrian.veloci

Adrián Lomas 614 Dec 4, 2022
Android library to create chat message view easily

ChatMessageView ChatMessageView helps you to create chat message view quickly like a typical chatting application. Its a container view, so you can ad

Himanshu Soni 641 Dec 24, 2022