Material style morphing play-pause drawable for Android

Overview

Play

License

There is no need to explain what this thing does, just take a look at the gif below.

Including in your project

Add to your root build.gradle:

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

Add the dependency:

dependencies {
    compile 'com.github.alxrm:youtube-play-icon:0.9'
}

Usage

PlayIconDrawable

You can use it as a Drawable, and insert into any ImageView, with beautiful fluent API like this:

final ImageView iconView = (ImageView) findViewById(R.id.icon_play);
final PlayIconDrawable play = PlayIconDrawable.builder()
    .withColor(Color.WHITE)
    .withInterpolator(new FastOutSlowInInterpolator())
    .withDuration(300)
    .withInitialState(PlayIconDrawable.IconState.PAUSE)
    .withAnimatorListener(new AnimatorListenerAdapter() {
      @Override public void onAnimationEnd(Animator animation) {
        super.onAnimationEnd(animation);
        Log.d("Animation", "animationFinished");
      }
    })
    .withStateListener(new PlayIconDrawable.StateListener() {
      @Override public void onStateChanged(PlayIconDrawable.IconState state) {
        Log.d("IconState", "onStateChanged: " + state);
      }
    })
    .into(iconView);

All of these methods can be ignored, so the drawable will be created with it's default state

There is an PlayIconView, which extends ImageView and simply draws the icon and provides an API to work with it. You can use it in any layout.

API

To change icon state w/o animation, you can use:

PlayIcon.setIconState(@NonNull PlayIconDrawable.IconState state)

and to do the same with beautiful morphing animation:

PlayIcon.animateToState(@NonNull PlayIconDrawable.IconState state)

you also can use a convenient toggle method:

PlayIcon.toggle(boolean animated);

if you need to know whether the state is changed, there is a handy StateListener, you can set one with:

PlayIcon.setStateListener(@Nullable PlayIconDrawable.StateListener listener);

for more info about API, take a look at this

Contribution

You are free to send me PRs and issues, I'd like to help you and improve this.

License

MIT License

Copyright (c) 2016 Alexey Derbyshev

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
You might also like...
Implementation of Ripple effect from Material Design for Android API 9+
Implementation of Ripple effect from Material Design for Android API 9+

RippleEffect ExpandableLayout provides an easy way to create a view called header with an expandable view. Both view are external layout to allow a ma

Material Design implementation for Android 4.0+. Shadows, ripples, vectors, fonts, animations, widgets, rounded corners and more.
Material Design implementation for Android 4.0+. Shadows, ripples, vectors, fonts, animations, widgets, rounded corners and more.

Carbon Material Design implementation for Android 4.0 and newer. This is not the exact copy of the Lollipop's API and features. It's a custom implemen

Android drawer icon with material design animation
Android drawer icon with material design animation

LDrawer Android drawer icon with material design animation Note Basically same as appcompat_v7 version 21, you can use appcompat_v7 compile 'com.andro

[] Android Library that implements Snackbars from Google's Material Design documentation.
[] Android Library that implements Snackbars from Google's Material Design documentation.

DEPRECATED This lib is deprecated in favor of Google's Design Support Library which includes a Snackbar and is no longer being developed. Thanks for a

A material horizontal calendar view for Android based on RecyclerView
A material horizontal calendar view for Android based on RecyclerView

Horizontal Calendar A material horizontal calendar view for Android based on RecyclerView. Installation The library is hosted on jcenter, add this to

Android Sample Project with Material Design and Toolbar.

AndroidMaterialDesignToolbar -- PROJECT IS NOT SUPPORTED Android Sample Project with Material Design and Toolbar. Project use Appcompat library for ma

Default colors and dimens per Material Design guidelines and Android Design guidelines inside one library.
Default colors and dimens per Material Design guidelines and Android Design guidelines inside one library.

Material Design Dimens Default colors and dimens per Material Design guidelines and Android Design guidelines inside one library. Dimens Pattern: R.di

Android drawer icon with material design animation
Android drawer icon with material design animation

LDrawer Android drawer icon with material design animation Note Basically same as appcompat_v7 version 21, you can use appcompat_v7 compile 'com.andro

Floating Action Button for Android based on Material Design specification
Floating Action Button for Android based on Material Design specification

FloatingActionButton Yet another library for drawing Material Design promoted actions. Features Support for normal 56dp and mini 40dp buttons. Customi

Comments
  • Cannot install. Failed to resolve

    Cannot install. Failed to resolve

    Error:(67, 13) Failed to resolve: com.github.alxrm:youtube-play-icon:0.9

    i have this in root gradle file

    repositories {
            google()
            jcenter()
            maven { url "https://jitpack.io" }
    }
    

    and this in app gradle file

        // Play pause icon anim
        compile 'com.github.alxrm:youtube-play-icon:0.9'
    
    opened by dengue8830 1
Releases(0.9)
  • 0.9(Dec 14, 2016)

Owner
Alexey Derbyshev
Alexey Derbyshev
Material style circular progress bar for Android

Material CircularProgressView Indeterminate Determinate Description This CircularProgressView is a (surprisingly) circular progress bar Android View t

Rahat Ahmed 760 Nov 30, 2022
A material style progress wheel compatible with 2.3

![](https://img.shields.io/badge/Methods and size-106 | 12 KB-e91e63.svg) Material-ish Progress A material style progress wheel compatible with 2.3 Tr

Nico Hormazábal 2.5k Jan 4, 2023
Navigation Drawer Activity with material design style and simplified methods

MaterialNavigationDrawer Navigation Drawer Activity with material design style and simplified methods       It requires 10+ API and android support v7

Fabio Biola 1.6k Jan 5, 2023
A material style progress wheel compatible with 2.3

![](https://img.shields.io/badge/Methods and size-106 | 12 KB-e91e63.svg) Material-ish Progress A material style progress wheel compatible with 2.3 Tr

Nico Hormazábal 2.5k Jan 4, 2023
Material Shadows for android : A library for supporting convex material shadows

MaterialShadows A library for seamlessly integrating Material shadows. The library takes existing material shadows to next level by adding the followi

Harjot Singh Oberai 2.2k Dec 19, 2022
📱Android Library to implement animated, 😍beautiful, 🎨stylish Material Dialog in android apps easily.

Material Dialogs for Android ?? ?? Android Library to implement animated, ?? beautiful, ?? stylish Material Dialog in android apps easily. 1. Material

Shreyas Patil 875 Dec 28, 2022
MaterialPickers-in-android - A simple android project that shows how to create material pickers for date and time

MaterialPickers-in-android A simple android project that shows how to create mat

Segun Francis 2 Apr 28, 2022
A library to bring fully animated Material Design components to pre-Lolipop Android.

Material MaterialLibrary is an Open Source Android library that back-port Material Design components to pre-Lolipop Android. MaterialLibrary's origina

Rey Pham 6k Dec 21, 2022
The flexible, easy to use, all in one drawer library for your Android project. Now brand new with material 2 design.

MaterialDrawer ... the flexible, easy to use, all in one drawer library for your Android project. What's included ?? • Setup ??️ • Migration Guide ??

Mike Penz 11.6k Dec 27, 2022
Floating Action Button for Android based on Material Design specification

FloatingActionButton Yet another library for drawing Material Design promoted actions. Features Support for normal 56dp and mini 40dp buttons. Customi

Zendesk 6.4k Dec 26, 2022