/ Animations

Android Marshmallow Boot Animation View

Android Marshmallow Boot Animation View

Android-Marshmallow-Boot-Animation

Android Marshmallow Boot Animation View.

animation_demo

To use LoadingAnimationView first add dependency to your project:

dependencies {
    compile 'com.cleveroad:androidmanimation:0.9.1'
}

Then you can declare it in your layout file like this:

    <com.cleveroad.androidmanimation.LoadingAnimationView
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/animation"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="16dp"
        app:lav_backgroundColor="@android:color/black"
        app:lav_firstColor="@color/google_red"
        app:lav_secondColor="@color/google_green"
        app:lav_thirdColor="@color/google_blue"
        app:lav_fourthColor="@color/google_yellow"
        app:lav_speedCoefficient="1.0"
        />

Pay attention that you need to manually start/pause/stop animation.

    private LoadingAnimationView animation;
    
    ...
    
    @Override
    protected void onResume() {
        super.onResume();
        // user interacts with screen, start animation
        animation.startAnimation();
    }

    @Override
    protected void onPause() {
        // user stops interacting with screen, pause animation, save your battery!
        animation.pauseAnimation();
        super.onPause();
    }

    @Override
    protected void onDestroy() {
        // user leaves screen. Clean up everything. 
        animation.stopAnimation();
        super.onDestroy();
    }

Another way to display loading animation is to use builder and display a dialog:

    AnimationDialogFragment fragment = new AnimationDialogFragment.Builder()
            .setBackgroundColor(Color.WHITE)
            .setFirstColor(getResources().getColor(R.color.google_red))
            .setSecondColor(getResources().getColor(R.color.google_green))
            .setThirdColor(getResources().getColor(R.color.google_blue))
            .setFourthColor(getResources().getColor(R.color.google_yellow))
            .setSpeedCoefficient(1.0f)
            .build();
    fragment.show(getSupportFragmentManager(), "Animation");

GitHub