{"id":18425695,"url":"https://github.com/zhanghai/materialplaypausedrawable","last_synced_at":"2026-01-11T17:41:52.810Z","repository":{"id":57736805,"uuid":"135376877","full_name":"zhanghai/MaterialPlayPauseDrawable","owner":"zhanghai","description":"Material Design play/pause Drawable with animation","archived":false,"fork":false,"pushed_at":"2019-05-16T04:07:38.000Z","size":1127,"stargazers_count":33,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-07-31T12:36:38.092Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zhanghai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-30T02:25:56.000Z","updated_at":"2022-09-02T02:27:56.000Z","dependencies_parsed_at":"2022-08-24T14:59:39.331Z","dependency_job_id":null,"html_url":"https://github.com/zhanghai/MaterialPlayPauseDrawable","commit_stats":null,"previous_names":["dreamingincodezh/materialplaypausedrawable"],"tags_count":1,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhanghai%2FMaterialPlayPauseDrawable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhanghai%2FMaterialPlayPauseDrawable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhanghai%2FMaterialPlayPauseDrawable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhanghai%2FMaterialPlayPauseDrawable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhanghai","download_url":"https://codeload.github.com/zhanghai/MaterialPlayPauseDrawable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223286478,"owners_count":17120000,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T05:04:57.481Z","updated_at":"2026-01-11T17:41:52.764Z","avatar_url":"https://github.com/zhanghai.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MaterialPlayPauseDrawable\n\n![Icon](sample/src/main/launcher_icon-web.png)\n\nMaterial Design play/pause Drawable with animation, compatible with Android 4.0+.\n\n## Why MaterialPlayPauseDrawable?\n\n- Correct play icon that is the same as the one in Material Design Icons, not horizontally stretched ([1](https://github.com/alexjlockwood/adp-path-morph-play-to-pause), [2](https://github.com/OHoussein/android-material-play-pause-view)).\n- Robust state handling that always animates to the correct final state without visual glitch.\n- Can be used flexibly as `Drawable`, `ImageView` or `ImageButton`.\n- `Drawable` comes with the intrinsic size of 24dp.\n- Compatible down to Android 4.0.\n\n## Preview\n\n\u003ca href=\"https://play.google.com/store/apps/details?id=me.zhanghai.android.materialplaypausedrawable.sample\" target=\"_blank\"\u003e\u003cimg alt=\"Google Play\" height=\"90\" src=\"https://play.google.com/intl/en_US/badges/images/generic/en_badge_web_generic.png\"/\u003e\u003c/a\u003e\n\n[Sample APK](//github.com/zhanghai/MaterialPlayPauseDrawable/releases/download/v1.0.0/sample-release.apk)\n\n![Sample app](preview/sample.gif)\n\n## Integration\n\nGradle:\n\n```gradle\nimplementation 'me.zhanghai.android.materialplaypausedrawable:library:1.0.0'\n```\n\n## Usage\n\n### As `ImageView` or `ImageButton`\n\nSimply use `MaterialPlayPauseView` (subclass of `ImageView`) or `MaterialPlayPauseButton` (subclass of `ImageButton`), e.g.\n\n```xml\n\u003cme.zhanghai.android.materialplaypausedrawable.MaterialPlayPauseButton\n    android:id=\"@+id/play_pause\"\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"wrap_content\"\n    android:tint=\"?colorAccent\" /\u003e\n```\n\nThe `Drawable` is by default black, so you might want to tint it with `android:tint`. The default size will be determined by the `Drawable` which will be `24dp`.\n\nSome interesting methods include `setAnimationDuration()`, `getState()`, `setState()` and `jumpToState()`, which you can use to control the play/pause state of the `Drawable`.\n\nImplementation detail: The `Drawable` actually internally holds up to three states, namely the previous, current and next state. Animation happens between the previous and current state, and the next state is used to save the upcoming state while animation is running. If `setState()` is called while animation is running, it will simply replace the next state so that when current animation ends it can seamlessly transition to the final state without a glitch, while discarding any intermediate states. (And just to make things clear, `getState()` always returns the most recent state set by `setState()`.)\n\n(This library is using `State.PLAY` and `State.PAUSE` to denote the two icons instead of using a `boolean`, because the latter can actually be confusing when `isPlaying == true` actually means showing a pause icon.)\n\n### As `Drawable`\n\nYou can also use the `MaterialPlayPauseDrawable` directly. It has an intrinsic size of `24dp` and default color of black. It also exposed the same methods namely `setAnimationDuration()`, `getPlayPauseState()` (renamed to avoid clashing with `Drawable.getState()`), `setState()` and `jumpToState()`.\n\nOne caveat is that on Android 7.0+, the framework uses `View.onVisibilityAggregated()` instead of `View.onVisibilityChanged()`, and it is broken in that it won't set our Drawable to invisible when the containing view is set to invisible before attached to the view hierarchy (e.g. when inside `onBindViewHolder()`). This can lead to erroneous animation when the view is later set to visible because our `Drawable` won't be able to skip its animation when it was invisible.\n\nTo work around this issue, I created `VisibilityAggregatedImageView` and `VisibilityAggregatedImageButton`, and you might want to use or derive from them when using the `Drawable` directly. (If you are using `MaterialPlayPauseView` or `MaterialPlayPauseButton`, this is automatically handled for you.)\n\n## License\n\n    Copyright 2018 Zhang Hai\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhanghai%2Fmaterialplaypausedrawable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhanghai%2Fmaterialplaypausedrawable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhanghai%2Fmaterialplaypausedrawable/lists"}