ToggleIconView is a collection library of animated two-stage toggle icons for Android.

Overview

JitPack

ToggleIconView

ToggleIconView is a collection library of animated two-stage toggle icons for Android.

Installation

JitPack repository

// Project level build.gradle
allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

If the above doesn't work for you, try the following:

// settings.gradle
...
dependencyResolutionManagement {
    ...
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}
...

Implementation

// App level build.gradle
dependencies {
    implementation "com.github.ozgurg:ToggleIconView:3.0.2"
}

Usage

<!-- See "Built-in icons" section for other icons -->
<og.android.lib.toggleiconview.rounded.PlayPause
    android:layout_width="24dp"
    android:layout_height="24dp" />

API

ToggleIconView, uses AnimatedVectorDrawableCompat under the hood and extends AppCompatImageView. So you can do anything you can with AppCompatImageView like tinting and other stuff. That's why I called it "collection library".

Attributes

Attribute Description Type Default
app:checked Sets the initial state of the icon Boolean false
app:checkedContentDescription Sets the initial checked content description of the icon String null
app:uncheckedContentDescription Sets the initial unchecked content description of the icon String null
app:checkedTooltipText Sets the initial checked tooltip text of the icon String null
app:uncheckedTooltipText Sets the initial unchecked tooltip text of the icon String null

Methods

Method Description Return
toggle() Toggles between the checked and unchecked state of the icon -
.isChecked
isChecked()
Returns the checked state of the icon Boolean
.isChecked = Boolean
setChecked(isChecked: Boolean)
Sets the checked state of the icon -
.checkedContentDescription
getCheckedContentDescription()
Returns the checked content description of the icon String?
.checkedContentDescription = String?
setCheckedContentDescription(value: String?)
Sets the checked content description of the icon -
.uncheckedContentDescription
getUncheckedContentDescription()
Returns the unchecked content description of the icon String?
.uncheckedContentDescription = String?
setUncheckedContentDescription(value: String?)
Sets the unchecked content description of the icon -
.checkedTooltipText
getCheckedTooltipText()
Returns the checked tooltip text of the icon String?
.checkedTooltipText = String?
setCheckedTooltipText(value: String?)
Sets the checked tooltip text of the icon -
.uncheckedTooltipText
getUncheckedTooltipText()
Returns the unchecked tooltip text of the icon String?
.uncheckedTooltipText = String?
setUncheckedTooltipText(value: String?)
Sets the unchecked tooltip text of the icon -

Events

Event Description
onCheckedChanged(view: ToggleIconView, isChecked: Boolean) Triggers when the checked state of the icon changed

Built-in icons

All icons have the same duration (@android:integer/config_shortAnimTime) and interpolator (@android:interpolator/fast_out_slow_in), but I manually capture their previews; so timings may look different.

Preview Package
[Rounded] PlayPause
og.android.lib.toggleiconview.rounded.PlayPause
[Sharp] PlayPause
og.android.lib.toggleiconview.sharp.PlayPause
[Rounded] SoundOnOff
og.android.lib.toggleiconview.rounded.SoundOnOff
[Sharp] SoundOnOff
og.android.lib.toggleiconview.sharp.SoundOnOff
[Sharp] FlashOnOff
og.android.lib.toggleiconview.sharp.FlashOnOff
[Sharp] AirplaneModeOnOff
og.android.lib.toggleiconview.sharp.AirplaneModeOnOff

How do you create your custom icon?

1) Create an icon

First, you need to create an AnimatedVectorDrawable icon. I highly recommend using Shape Shifter.

After creating and exporting your icon, add the icon to your project's drawable folder.

2) Implement the icon

Extend ToggleIconView class and set checked and unchecked icon you created.

package [PACKAGE_NAME]

import android.content.Context
import android.util.AttributeSet
import og.android.lib.toggleiconview.R
import og.android.lib.toggleiconview.ToggleIconView

class [NAME_YOUR_ICON] @JvmOverloads constructor(
    context: Context,
    attrs: AttributeSet? = null,
    defStyleAttr: Int = 0
) :
    ToggleIconView(
        context, attrs, defStyleAttr,
        R.drawable.[CHECKED_ICON],
        R.drawable.[UNCHECKED_ICON]
    )

Then, use it in your layout.

<[PACKAGE_NAME].[NAME_YOUR_ICON]
    android:layout_width="24dp"
    android:layout_height="24dp" />

License

License

You might also like...
[] 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

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

A library support form with material design, construct same with Android UI Framework

SwingUI A slight Java Swing library support form with material design, construct same with Android UI Framework writen in Kotlin Supported: 1. Screen:

A Material Design ViewPager easy to use library
A Material Design ViewPager easy to use library

MaterialViewPager Material Design ViewPager easy to use library Sample And have a look on a sample Youtube Video : Youtube Link Download In your modul

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 material pickers for date and time

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

😍 A beautiful, fluid, and extensible dialogs API for Kotlin & Android.
😍 A beautiful, fluid, and extensible dialogs API for Kotlin & Android.

Material Dialogs View Releases and Changelogs Modules The core module is the fundamental module that you need in order to use this library. The others

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

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

Releases(3.0.2)
Library containing over 2000 material vector icons that can be easily used as Drawable or as a standalone View.

Material Icon Library A library containing over 2000 material vector icons that can be easily used as Drawable, a standalone View or inside menu resou

null 2.3k Dec 16, 2022
Animations for Android L drawer, back, dismiss and check icons

Material Menu Morphing Android menu, back, dismiss and check buttons Have full control of the animation: Including in your project compile 'com.balysv

Balys Valentukevicius 2.5k Jan 3, 2023
Material Design icons by Google

Material design icons Material design icons is the official icon set from Google. The icons are designed under the material design guidelines. 4.0.0 U

Google 47.1k Jan 9, 2023
📱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
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
Animated Material circular button

Material Circular Button Circular button for Android in Google Material Style How to use Clone this proyect and import the module "materialCircularBut

Adrián Lomas 217 Nov 25, 2022
This is a library with components of Android L to you use in android 2.2

Material Design Android Library How to use Components Buttons Flat Button Rectangle Button Float Button Float small button Switches CheckBox Switch Pr

Ivan Navas 9.1k Jan 5, 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
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
An Android library aimed to get the beautiful CardViews that Google shows at its official design specifications

MaterialList Discontinued This library will not receive any updates, as I do not have the time or knowledge to improve it. If anyone forks it and want

null 1.6k Nov 29, 2022