Code Monkey home page Code Monkey logo

lineanimation's Introduction

LineAnimation

Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
    ...
        maven { url 'https://jitpack.io' }
    }
}

Add the dependency

dependencies {
    implementation 'com.github.tushar09:LineAnimation:1.1.9'
}

Add this in your layout:

<com.captaindroid.lineanimation.Animator
        android:id="@+id/la_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:dashPathSize="12dp"
        app:dashPathGap="12dp"
        app:pathColor="@color/colorAccent"
        app:pathStrokeWidth="4dp"
        app:drawable="@drawable/your_drawable"
        app:enableDashPath="true"
        app:drawableAminationSpeed="5"
        app:repeatable="true" />

In your activity implement the OnPathListener

public class MainActivity extends AppCompatActivity implements OnPathListener {

    private Animator animator;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        animator = findViewById(R.id.la_view);
        animator.startAnimateArrow();
    }

    @Override
    public Path setOnPathUpdateListener(int bitmapPositionX, int bitmapPositionY){
        Path p = new Path();
        p.moveTo(animator.getWidth() / 2, 0);
        p.cubicTo(0, animator.getHeight() / 2, animator.getWidth(), animator.getHeight() / 2, animator.getWidth() / 2, animator.getHeight());
        //or
        //p.addCircle(...);
        //p.addArc(...);
        //p.quadTo(...);
        //just add an return your custom path
        return p;
    }

    @Override
    public void setOnAnimationCompleteListener() {
        // completed the animation
    }
}

You can use getter setter method too in java class:

//getter and setter
animator.getPathColor();
animator.setPathColor(int pathColor);
animator.getDashPathSize();
animator.setDashPathSize(int dashPathSize);
animator.getDashPathGap();
animator.setDashPathGap(int dashPathGap);
animator.getPathStrokeWidth();
animator.setPathStrokeWidth(int pathStrokeWidth);
animator.getDrawableAnimationSpeed();
animator.setDrawableAnimationSpeed(int drawableAnimationSpeed);
animator.getDrawable();
animator.setDrawable(int drawable);
animator.isEnableDashPath();
animator.setEnableDashPath(boolean enableDashPath);
animator.isRepeatable();
animator.setRepeatable(boolean repeatable);

Please don't forget to give it a star if you like it.

lineanimation's People

Contributors

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